Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Info #15

Open
s2t2 opened this issue Mar 28, 2021 · 0 comments
Open

React Info #15

s2t2 opened this issue Mar 28, 2021 · 0 comments

Comments

@s2t2
Copy link
Member

s2t2 commented Mar 28, 2021

Can be run on client side with some imports. Doesn't require node.js. Would be good to provide a client-side example before we go into Node.js.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <div id="root"></div>

    <script type="application/javascript" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
    <script type="application/javascript" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
    <script type="application/javascript" src="https://unpkg.com/[email protected]/babel.js"></script>
    <script type="text/babel">
        // adapted from: https://dev.to/luispa/lets-try-react-without-nodejs-3a7

        class ShoppingList extends React.Component {
            render() {
                return (
                    <div className="shopping-list">
                        <h1>Shopping List for {this.props.name}</h1>
                        <ul>
                            <li>Instagram</li>
                            <li>WhatsApp</li>
                            <li>Oculus</li>
                        </ul>
                    </div>
                );
            }
        }

        function App(){
            return(
                <div>
                    <h1>This is a react app</h1>
                    <ShoppingList name="Sammy Student"/>
                    <ShoppingList name="Jane Jogger"/>
                </div>
            )
        }

        ReactDOM.render(<App/>, document.getElementById("root"))
    </script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant