How to transfer this.state to react-routes?

By : batazor
Source: Stackoverflow.com
Question!

I use the react-router and ES6, both in the new react-router to pass a value to the component? I used use <Handler name = {this.state.name} /> now used {this.props.children}. How to transfer data to it from the App in the Components?

How to transfer this.state to react-routes with:

export default class App extends React.Component{

  constructor () {
    this.state = { name: 'Username' };
  }

  render () {
    return (
      <div>
        {this.props.children} // <-- this.state ???
      </div>
    );
  }
};

React.render((
  <Router history={HashHistory}>
    <Route path="" component={App}>
      <Route path="about" component={About} />
    </Route>
  </Router>
), document.getElementById('app'));

{this.props.children} // <-- this.state ???

By : batazor


Answers

I would recommend to access the information you store in App.state from separate Flux stores and then access them in each component you need. React router should not be involved into passing the data between routes.



This video can help you solving your question :)
By: admin