Created
July 8, 2014 12:08
-
-
Save joecritch/0bf7855bfc58df8c7f06 to your computer and use it in GitHub Desktop.
Using Flux in react-nested-router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @jsx React.DOM | |
*/ | |
var React = require('react'); | |
var App = require('components/App/App.jsx'); | |
var Layout = React.createClass({ | |
render: function() { | |
var node = this.props.flux ? App : React.DOM.div; | |
return ( | |
<node flux={this.props.flux}> | |
{this.props.activeRoute} | |
</node> | |
); | |
} | |
}); | |
module.exports = Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .... << dependency set up >> .... | |
var flux = new Fluxxor.Flux(stores, actions); | |
React.renderComponent( | |
Route({handler: Layout, flux: flux}, | |
Route({name: 'home', path: '/', handler: Home, flux: flux}) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an attempt to use Fluxxor within react-nested-router. Layout handles the rendering of the
App
component oncethis.props.flux
is passed from the router.