Skip to content

Instantly share code, notes, and snippets.

@h4091
Last active December 28, 2018 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h4091/d90c7ff215492aed430922f3bfcbba04 to your computer and use it in GitHub Desktop.
Save h4091/d90c7ff215492aed430922f3bfcbba04 to your computer and use it in GitHub Desktop.
Test12
<div id="root"></div>
function UserGreeting(props) {
return <h1>Welcome back!</h1>;
}
function GuestGreeting(props) {
return <h1>Please sign in.</h1>;
}
function Greeting(props) {
const isLoggedIn = props.isLoggedIn;
if (isLoggedIn) {
return <UserGreeting />;
}
return <GuestGreeting />;
}
ReactDOM.render(
<Greeting isLoggedIn={false} />,
document.getElementById("root")
);
<script src="https://unpkg.com/react/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>

Test12

Learn the fundamentals of React, including simple and class components, state, props, and submitting form data.

Conditional rendering

A Pen by 你银子掉了 on CodePen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment