passing data between react components code example
Example 1: passing data in route react
<Route path="/" render={() => <Search name={this.props.name} />} />
Example 2: passing data in route react
<Route path="/" component={() => <Search name={this.props.name} />} />
Example 3: passing data in route react
render={routeProps => <Search name={this.props.name} {...routeProps} />}
Example 4: passing data in route react
<Route path="/:name" component={Search} />
Example 5: how to pass state from parent to child in react
class SomeParentComponent extends React.Component {
constructor(props) {
super(props);
this.state = {color: 'red'};
}
render() {
return <SomeChildComponent color={this.state.color} />;
}
}