Skip to content

Commit

Permalink
add more details to the ui state exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Mar 7, 2024
1 parent efc9217 commit c3dd199
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions exercises/01.managing-ui-state/README.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
# Managing UI State

Normally an interactive application will need to hold state somewhere. In React,
you use special functions called "hooks" to do this. Common built-in hooks
include:
Dynamic applications allow users to interact and make changes to what they see
on the page and the application should respond by updating the UI based on what
the user has done. We accomplish this by using state. When state changes (for
example as the result of user interaction and input), we update the UI. Here's
how that works with React:

```
render --> set up the DOM ↙
user interacts --> state changes ↙
re-render --> update the DOM ↖
```

From there's a cycle of user interaction, state changes, and re-rendering. This
is the core of how React works for interactive applications.

The `render` phase is what what we've done so far with creating React elements.
Handling user interactions is what we've done with event listeners like
`onSubmit`. Now we're going to get into the `state changes` bit.

In React, you use special functions called "hooks" to do this. Common built-in
hooks include:

- `useState`
- `useRef`
Expand Down

0 comments on commit c3dd199

Please sign in to comment.