Lesson 3 of 39
Lesson Progress: 0%
function Greeting(props) {
return (
<div>
{props.isLoggedIn ? <p>Welcome back!</p> : <p>Please log in.</p>}
</div>
);
}
render(<Greeting isLoggedIn={true} />);Instructions
▼ ← Click the triangle to hide or reveal instructions.function at the beginning.function Greeting(props) { means we are making a component named Greeting, and props holds the value passed into it.? means "show this if true" and the : means "otherwise show this."{props.isLoggedIn ? <p>Welcome back!</p> : <p>Please log in.</p>} checks the isLoggedIn value and shows one message if it is true, or a different message if it is false.function MessageStatus(props) {
return (
<div>
{props.hasMessages ? <p>You have new messages.</p> : <p>No new messages.</p>}
</div>
);
}
render(<MessageStatus hasMessages={false} />);Instructions
▼ ← Click the triangle to hide or reveal instructions.function at the beginning.function MessageStatus(props) { makes a component named MessageStatus, and props holds the value passed into it.? means "show this if true" and the : means "otherwise show this other part."const Greeting = function (props) {
return (
<div>
{props.isLoggedIn ? <p>Welcome back!</p> : <p>Please log in.</p>}
</div>
);
};
render(<Greeting isLoggedIn={true} />);Instructions
▼ ← Click the triangle to hide or reveal instructions.function when the function is written.const Greeting = function (props) { means we are storing a function in the Greeting variable, and props receives the passed-in value.? means "if true, show this" and the : means "otherwise, show this other part."Instructions
▼ ← Click the triangle to hide or reveal instructions.function when the function is written.const MessageStatus = function (props) { means we are storing a function in the MessageStatus variable, and props receives the value that is passed in.? means "if true, show this" and the : means "otherwise, show this other part."Instructions
▼ ← Click the triangle to hide or reveal instructions.function, and uses => instead.const Greeting = (props) => { means we are saving the component in the Greeting variable, and props receives the value passed in.? means "if true, show this" and the : means "otherwise, show this other part."Instructions
▼ ← Click the triangle to hide or reveal instructions.function and uses => instead.const MessageStatus = (props) => { means we are saving the function in the MessageStatus variable, and props receives the value passed in.? means "if true, show this" and the : means "otherwise, show this other part."Instructions
▼ ← Click the triangle to hide or reveal instructions.function and uses => instead.const OnlineStatus = (props) => { means we are saving the function in the OnlineStatus variable, and props receives the value passed in.? means "if true, show this" and the : means "otherwise, show this other part."Test Incomplete
const MessageStatus = function (props) {
return (
<div>
{props.hasMessages ? <p>You have new messages.</p> : <p>No new messages.</p>}
</div>
);
};
render(<MessageStatus hasMessages={false} />);const Greeting = (props) => {
return (
<div>
{props.isLoggedIn ? <p>Welcome back!</p> : <p>Please log in.</p>}
</div>
);
};
render(<Greeting isLoggedIn={true} />);const MessageStatus = (props) => {
return (
<div>
{props.hasMessages ? <p>You have new messages.</p> : <p>No new messages.</p>}
</div>
);
};
render(<MessageStatus hasMessages={false} />);const OnlineStatus = (props) => {
return (
<div>
{props.isOnline ? <p>User is online.</p> : <p>User is offline.</p>}
</div>
);
};
render(<OnlineStatus isOnline={true} />);