class Counter extends React.Component
constructor(props)
super(props);
this.state = count: 0 ;
this.increment = this.increment.bind(this); // Ugly binding
increment()
this.setState( count: this.state.count + 1 );
render()
return (
<div>
<p>Count: this.state.count</p>
<button onClick=this.increment>+1</button>
</div>
);
Let’s evaluate the course against its own promise.
With a clean foundation set, Mosh guided the class through the specific magic of React 18.
He introduced Hooks, the magical functions that let functional components possess state. He taught useState to remember data and useEffect to synchronize with the outside world. code mosh react 18 beginners fco better
But he didn't just teach the syntax; he taught the why.
Then came the crown jewel of React 18: Automatic Batching. Mosh demonstrated how React 18 intelligently groups multiple state updates into a single re-render for better performance, something previous versions struggled with. He made performance optimization feel effortless. class Counter extends React
Now, let's discuss the FCO part of our keyword. FCO stands for Functional Components Only.
Five years ago, React had two ways to write components: Class Components (with this.state and this.setState) and Functional Components (stateless). Today, thanks to Hooks (introduced in React 16.8 and matured in React 18), Functional Components can do everything class components can do—and more. Let’s evaluate the course against its own promise
Generate unique IDs that are stable across server/client:
import useId from 'react';
function Checkbox()
const id = useId();
return (
<>
<input id=id type="checkbox" />
<label htmlFor=id>Check me</label>
</>
);