reactjs - React - REST Defined List of components by REST -
i'm going explain i'am trying achieve in flux/react application.
this routing :
var routes = ( <route name="layout" path="/" handler={layout}> <route name="page" path=':section/:detail' handler={page} /> <route name="login" path='/login' handler={login}/> <defaultroute handler={layout}/> </route> ); exports.start = function() { router.run(routes, function (handler, state) { var params = state.params; react.render(<handler params={params}/>, document.body); }); }
i have rest service giving returning array of components described objects :
{ "components" : { "header" : { //data }, "tabs" : { //data } } }
basically tough have page.jsx component can handle data given rest api , define page structure.
i'm having trouble understanding how manage whole flow.
- where should retrive data ?
- in getinitialstate ?
- in componentdidmount ?
- in render ?
2 render component :
i'm trying manage :
var avaiblecomponents = { header : "header", tabs : "tabs" }; var components = data.components; var element = react.createelement(avaiblecomponents[i]); var rendered = react.render(element, document.getelementbyid('rsec-page-container'));
so i'm bit confused, wondering if me out somehow.
thanks
Comments
Post a Comment