Skip to content

Instantly share code, notes, and snippets.

@eltonjuan
Created Feb 4, 2016
Embed
What would you like to do?
LOL
import React from 'react';
import ReactDOM from 'react-dom';
// TODO remove relative path madness
import FavoritesStarButton from './FavoritesStarButtonReact';
const JunoFavoritesStarButton = {
is: 'view/components/favoritesstarbutton/FavoritesStarButton',
defaults() {
return {
props: {
product: '',
isFavorite: false,
},
reactNode: <FavoritesStarButton isFavorite={this.isFavorite} product={this.product} />,
};
},
postRender() {
ReactDOM.render(
React.cloneElement(this.reactNode, {
product: this.product,
isFavorite: this.isFavorite,
}),
this.el
);
},
postUpdate() {
ReactDOM.render(
React.cloneElement(this.reactNode, {
product: this.product,
isFavorite: this.isFavorite,
}),
this.el
);
},
preDestroy() {
ReactDOM.unmountComponentAtNode(this.el);
},
};
export default juno.ViewComponent.extend(JunoFavoritesStarButton);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment