<MovieIdea title="Interstellar" description="Love across time and space" /> import useState from 'react'; function LikeButton() const [likes, setLikes] = useState(0);
return ( <button onClick=() => setLikes(likes + 1)> 👍 likes </button> ); code mosh react 18 beginners fco
If two components need same data → move state to closest common parent. import useState from 'react'
function MovieIdea( title, description ) return ( <div> <h3>title</h3> <p>description</p> </div> ); function LikeButton() const [likes
⚠️ Always use a unique key . function DeleteButton( onDelete ) return <button onClick=onDelete>Delete</button>;
useEffect(() => fetch('https://movie-quote-api.com/random') .then(res => res.json()) .then(data => setFact(data.quote)); , []); // empty array = run once