- Abhinay Bathina
- Kaushik Rishi
function UserCard() {
return (
<div>
{isLoading ? (
<LoadingIcon />
) : (
<div>
<UserProfilePhoto />
<UserInfo />
</div>
)}
</div>
);
}
Most important terms in React
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App />,
document.getElementById('root')
);function App() {
return <Welcome name="rishi" />
}
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}Accessed via state variable used in useState destructuring
import React, { useState } from 'react';
function Example() {
// Declare a new state variable, which we'll call "count"
const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>
Click me
</button>
</div>
);
}function getGreeting(user) {
if (user) {
return <h1>Hello, {formatName(user)}!</h1>;
}
return <h1>Hello, Stranger.</h1>;
}