Giới thiệu Components trong ReactJS.

Mã nguồn tham khảo:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Component</title>
    <script src="https://npmcdn.com/[email protected].3.0/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>
    <div id="example-2"></div>

    <script type="text/babel">
        var Barcon = React.createClass({
            render: function() {
                return (
                    <div>
                        <h3>This is a simple component!</h3>
                        <p>This is content.</p>
                    </div>
                );
            }
        });

        ReactDOM.render(<Barcon />, document.getElementById('example')); // Single Component
        ReactDOM.render(<Barcon />, document.getElementById('example-2')); // Single Component
    </script>
</body>
</html>