Skip to content

Commit a4711d1

Browse files
committed
Add missing commas and words
1 parent ab3325d commit a4711d1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: student-lesson-notes.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# Student Learning Notes
22

3-
The workshop has lectures followed by exercises. The Exercises are your chance to write code so we hope you're able to sit back and enjoy the lectures without feeling like you have to code-along at our fast pace. You're encouraged to take notes, but we don't want that to get in the way of listening to the lecture. So we made you notes for you. This is your repo so feel free to make edits.
3+
The workshop has lectures followed by exercises. The Exercises are your chance to write code, so we hope you're able to sit back and enjoy the lectures without feeling like you have to code-along at our fast pace. You're encouraged to take notes, but we don't want that to get in the way of listening to the lecture. So we made notes for you. This is your repo so feel free to make edits.
44

55
---
66

77
## Lesson 1: Rendering
88

99
- We like React because it's Composable and Declarative
1010
- Composable: You can build small re-usable parts which can be used to build bigger, more complex things
11-
- Declarative: We write in a style where we say "what" we want. In other words `<Tabs>` is declarative because we said we want tabs but we didn't have to program "how" they work. Whoever did program the internals of <Tabs> programmed "how" they work. All declarative code that we write has imperative code somewhere else that someone else wrote.
11+
- Declarative: We write in a style where we say "what" we want. In other words `<Tabs>` is declarative because we said we want tabs, but we didn't have to program "how" they work. Whoever did program the internals of <Tabs> programmed "how" they work. All declarative code that we write has imperative code somewhere else that someone else wrote.
1212
- JSX is a syntax for easily creating nested elements. Babel is a Webpack plugin that converts each JSX "tag" into `React.createElement`
1313
- The return value of a component (JSX turned into `React.createElement`) is like an "instruction manual" for how to create DOM.
1414
- In a typical React application, `ReactDOM.render()` is only used once. As React changes our JSX responses from our components, React will also take care of updating the DOM to reflect those JSX changes.
1515
- A function that returns JSX is a "component" in React. There are also older ways of creating components with classes. Function-based and class-based components can intermingle in the same app.
1616

1717
Docs: https://reactjs.org/docs/introducing-jsx.html
18+
1819
JSX Confusing Parts: https://reacttraining.com/blog/jsx-the-confusing-parts/
1920

2021
---
@@ -53,7 +54,7 @@ Docs: https://reactjs.org/docs/hooks-state.html
5354
## Lesson 4: Effects
5455

5556
- `useEffect` Format: `useEffect(callbackFunction, [dependencyArray])`
56-
- `useEffect` is used for side effects. Typically this means we want to do something outside of our component like a network request or perhaps with cookies/localstorage and we want to do that side effect any time state changes.
57+
- `useEffect` is used for side effects. Typically this means we want to do something outside of our component, like a network request or perhaps with cookies/localstorage, and we want to do that side effect any time state changes.
5758
- The effect callback runs when the component first mounts and then anytime the values in the dependency array change. Having an empty dependency array is a way to ensure the effect only runs once.
5859
- However, be careful, any variables that your effect uses (depends on) need to be stated in your dependency array. With the older mental model of time and `componentDidMount`, we thought in terms of "this just needs to happen once when we mount". But now with `useEffect` we need to think in terms of "anytime state changes, what do I need to do". Therefore you'll probably need to put values in your dependency array often.
5960

@@ -75,7 +76,7 @@ useEffect(fn, [some, state]) // runs when some state changes
7576
- Network requests and subscriptions are side effects and need to go in `useEffect`.
7677
- Avoid infinite loops: If an effect has no dependency array and also sets state, this will cause an infinite loop. Imagine that the component mounts which calls the effect. Then state is changed which leads to a re-render which means the effect will be called again because there was no dependency array telling react not to run the effect again. Then since the effect runs again and sets state, this creates an infinite loop.
7778
- In the callback for the effect, you can either return no value or return a function. If a function is returned, it's said to be the "cleanup function". This function is called when the component unmounts or when the dependency array changes.
78-
- When setting state asynchronously in an effect, there's always a chance the component will become unmounted the dependency array might change before the set state is called. For both cases, we need to use a cleanup function to ensure we're not setting state on the unmounted component or setting state that was based on the previous values of the dependency array. This is how we might prevent this problem with a `isCurrent` variable:
79+
- When setting state asynchronously in an effect, there's always a chance the component will become unmounted or the dependency array might change before the set state is called. For both cases, we need to use a cleanup function to ensure we're not setting state on the unmounted component or setting state that was based on the previous values of the dependency array. This is how we might prevent this problem with a `isCurrent` variable:
7980

8081
```js
8182
useEffect(() => {
@@ -120,7 +121,7 @@ useEffect(() => {
120121
- A component can be a "child component" in respect to its parent, but could also be a parent component because it further has child components.
121122
- This relationship between components builds a tree structure that will probably resemble the DOM tree structure that React is building for you.
122123
- Data flows down: React's data model is said to be "uni-directional", meaning data flows from parent components down through the tree to child components. However, if a prop is passed down from parent to child and the prop is a callback function, then we might say that child components can communicate back up to their parents by calling the function.
123-
- This makes passing data back and fourth through parent/child hierarchies pretty easy. However when components need to communicate with other components far away in this tree structure, the conventional solution has been to "lift state". In other words, if two components need to communicate we need to put state in one of their common ancestor (parent) components. Then one of the child components can communicate to the parent (through callback function props), which might lead to a state change and then the parent component can propagate that change down the tree to the other child component(s).
124+
- This makes passing data back and forth through parent/child hierarchies pretty easy. However, when components need to communicate with other components far away in this tree structure, the conventional solution has been to "lift state". In other words, if two components need to communicate we need to put state in one of their common ancestor (parent) components. Then one of the child components can communicate to the parent (through callback function props), which might lead to a state change and then the parent component can propagate that change down the tree to the other child component(s).
124125
- Context is another React feature that is an alternative way to pass information around our React tree structure that doesn't involve deep prop drilling.
125126

126127
- Docs on "Lifting State": https://reactjs.org/docs/lifting-state-up.html

0 commit comments

Comments
 (0)