Skip to content

Instantly share code, notes, and snippets.

@stutrek
Created July 5, 2016 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stutrek/650be2f8b40a51318a16a6ad9c716eef to your computer and use it in GitHub Desktop.
Save stutrek/650be2f8b40a51318a16a6ad9c716eef to your computer and use it in GitHub Desktop.
var ItemView = require('marionette').ItemView;
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import store from 'app/store';
class MarionetteContainer extends React.Component {
render () {
return (
<Provider store={store}>
{this.props.children}
</Provider>
);
}
}
module.exports = ItemView.extend({
template: function () { return ''; },
onClose: function () {
ReactDOM.unmountComponentAtNode(this.$el[0]);
},
onShow: function () {
if (typeof this.renderComponent !== 'function') {
throw new TypeError('To use React in Marionette you must add a renderComponent method to your view.');
}
ReactDOM.render((
<MarionetteContainer>
{this.renderComponent()}
</MarionetteContainer>
), this.$el[0]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment