Giới thiệu Props trong ReactJS.
Mã nguồn tham khảo:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Props</title> <script src="https://npmcdn.com/[email protected]/dist/react.min.js"></script> <script src="https://npmcdn.com/[email protected]/dist/react-dom.min.js"></script> <script src="https://npmcdn.com/[email protected]/browser.min.js"></script> </head> <body> <div id="example"></div> <script type="text/babel"> var Movie = React.createClass({ render: function() { return ( <div> <h3>{this.props.title}</h3> <p>{this.props.genre}</p> </div> ); } }); ReactDOM.render(<Movie title="Avatar" genre="Ski-fi" />, document.getElementById('example')); </script> </body> </html>