If you want to pass parameters to components in React Native? First off render does not take any parameters, what you want to do is to reference your props that you passed in.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | var NavBar = React.createClass({ render: function () { return <div id="navbar" style={{backgroundColor: this.props.tintColor}}> <h1 style={{color: this.props.title.tintColor}}>{this.props.title.title}</h1> </div>; } }); var NavigationBar = React.createClass({ render: function() { var titleConfig = { title: this.props.title, tintColor: this.props.titleColor, }; return ( <NavBar title={titleConfig} tintColor={this.props.NavBarColor} /> ); } }); React.render(<NavigationBar title="Categories" titleColor="#ff0" NavBarColor="#f0b210" />, document.body); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.