File tree 1 file changed +21
-3
lines changed
exercises/01.managing-ui-state
1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 1
1
# Managing UI State
2
2
3
- Normally an interactive application will need to hold state somewhere. In React,
4
- you use special functions called "hooks" to do this. Common built-in hooks
5
- include:
3
+ Dynamic applications allow users to interact and make changes to what they see
4
+ on the page and the application should respond by updating the UI based on what
5
+ the user has done. We accomplish this by using state. When state changes (for
6
+ example as the result of user interaction and input), we update the UI. Here's
7
+ how that works with React:
8
+
9
+ ```
10
+ render --> set up the DOM ↙
11
+ user interacts --> state changes ↙
12
+ re-render --> update the DOM ↖
13
+ ```
14
+
15
+ From there's a cycle of user interaction, state changes, and re-rendering. This
16
+ is the core of how React works for interactive applications.
17
+
18
+ The ` render ` phase is what what we've done so far with creating React elements.
19
+ Handling user interactions is what we've done with event listeners like
20
+ ` onSubmit ` . Now we're going to get into the ` state changes ` bit.
21
+
22
+ In React, you use special functions called "hooks" to do this. Common built-in
23
+ hooks include:
6
24
7
25
- ` useState `
8
26
- ` useRef `
You can’t perform that action at this time.
0 commit comments