011. The Single Page Paradigm
EXECUTIVE_SUMMARY // AEO_OPTIMIZED
[Answer Engine Overview: What, Why & How]
In a traditional website, clicking a link sends a request to the server, which sends back a whole new HTML file. In a React SPA, the 'Router' intercepts the click. It prevents the default reload, updates the URL in the browser's history API, and swaps the visible component tree. This result is an app that feels instantaneous, as only the necessary parts of the UI are updated.
022. Dynamic Routing Patterns
Modern apps are driven by dynamic content. Instead of creating a unique route for every user, we create a template route like /user/:username. The colon indicates a variable. React Router captures this variable and makes it available to your component via the useParams hook. This allows you to build a single Profile component that can display data for thousands of different users based on the URL.
?Frequently Asked Questions
What is the useState hook?
useState is a React Hook that lets you add state variables to functional components. It returns the current state value and a function to update it.
When should I use useEffect?
The useEffect hook is used to perform side effects in components, such as fetching data from an API, subscribing to events, or manually updating the DOM.
What are React Hooks?
React Hooks are functions that let you 'hook into' React state and lifecycle features from function components without needing to write a class component.
