Skip to content

Commit 15dc072

Browse files
committed
Fix typos
1 parent 66254e2 commit 15dc072

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Diff for: README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ Hide/Show table of contents
612612

613613
The usage of Error boundaries from the above library is quite straight forward.
614614

615-
> **_Note when using react-error-boundary:_** ErrorBoundary is a client component. You can only pass props to it that are serializeable or use it in files that have a `"use client";` directive.
615+
> **_Note when using react-error-boundary:_** ErrorBoundary is a client component. You can only pass props to it that are serializable or use it in files that have a `"use client";` directive.
616616

617617
```jsx
618618
"use client";
@@ -1254,7 +1254,7 @@ class ParentComponent extends React.Component {
12541254
12551255
30. ### Why React uses `className` over `class` attribute?
12561256
1257-
The attribute names written in JSX turned into keys of JavaScript objects and the JavaScript names cannot contain dashes or reversed words, it is recommended to use camelCase whereever applicable in JSX code. The attribute `class` is a keyword in JavaScript, and JSX is an extension of JavaScript. That's the principle reason why React uses `className` instead of `class`. Pass a string as the `className` prop.
1257+
The attribute names written in JSX turned into keys of JavaScript objects and the JavaScript names cannot contain dashes or reversed words, it is recommended to use camelCase wherever applicable in JSX code. The attribute `class` is a keyword in JavaScript, and JSX is an extension of JavaScript. That's the principle reason why React uses `className` instead of `class`. Pass a string as the `className` prop.
12581258
12591259
```jsx harmony
12601260
render() {
@@ -4957,7 +4957,7 @@ class ParentComponent extends React.Component {
49574957
}
49584958
```
49594959
4960-
Because the declarative approach separates concerns, this part of it only needs to handle how the UI should look in a sepecific state, and is therefore much simpler to understand.
4960+
Because the declarative approach separates concerns, this part of it only needs to handle how the UI should look in a specific state, and is therefore much simpler to understand.
49614961
49624962
**[⬆ Back to Top](#table-of-contents)**
49634963
@@ -5520,7 +5520,7 @@ class ParentComponent extends React.Component {
55205520
}
55215521
```
55225522
5523-
The preceeding code updated two state variables with in an event handler. However, React will perform automatic batching feature and the component will be re-rendered only once for better performance.
5523+
The preceding code updated two state variables with in an event handler. However, React will perform automatic batching feature and the component will be re-rendered only once for better performance.
55245524
55255525
**[⬆ Back to Top](#table-of-contents)**
55265526
@@ -5597,7 +5597,7 @@ class ParentComponent extends React.Component {
55975597
55985598
256. ### How do you update objects inside state?
55995599
5600-
You cannot update the objects which exists in the state directly. Instead, you should create a fresh new object (or copy from the existing object) and update the latest state using the newly created object. Eventhough JavaScript objects are mutable, you need to treate objects inside state as read-only while updating the state.
5600+
You cannot update the objects which exists in the state directly. Instead, you should create a fresh new object (or copy from the existing object) and update the latest state using the newly created object. Eventhough JavaScript objects are mutable, you need to treat objects inside state as read-only while updating the state.
56015601
56025602
Let's see this comparison with an example. The issue with regular object mutation approach can be described by updating the user details fields of `Profile` component. The properties of `Profile` component such as firstName, lastName and age details mutated in an event handler as shown below.
56035603
@@ -5683,7 +5683,7 @@ class ParentComponent extends React.Component {
56835683
user.address.country = "Germany";
56845684
```
56855685
5686-
This issue can be fixed by flattening all the fields into a top-level object or create a new object for each nested object and point it to it's parent object. In this example, first you need to create copy of address object and update it with the latest value. Later, the adress object should be linked to parent user object something like below.
5686+
This issue can be fixed by flattening all the fields into a top-level object or create a new object for each nested object and point it to it's parent object. In this example, first you need to create copy of address object and update it with the latest value. Later, the address object should be linked to parent user object something like below.
56875687
56885688
```js
56895689
setUser({
@@ -5703,7 +5703,7 @@ class ParentComponent extends React.Component {
57035703
57045704
Eventhough arrays in JavaScript are mutable in nature, you need to treat them as immutable while storing them in a state. That means, similar to objects, the arrays cannot be updated directly inside state. Instead, you need to create a copy of the existing array and then set the state to use newly copied array.
57055705
5706-
To ensure that arrays are not mutated, the mutation operations like direct direct assigment(arr[1]='one'), push, pop, shift, unshift, splice etc methods should be avoided on original array. Instead, you can create a copy of existing array with help of array operations such as filter, map, slice, spread syntax etc.
5706+
To ensure that arrays are not mutated, the mutation operations like direct direct assignment(arr[1]='one'), push, pop, shift, unshift, splice etc methods should be avoided on original array. Instead, you can create a copy of existing array with help of array operations such as filter, map, slice, spread syntax etc.
57075707
57085708
For example, the below push operation doesn't add the new todo to the total todo's list in an event handler.
57095709
@@ -5743,7 +5743,7 @@ class ParentComponent extends React.Component {
57435743
2. Replace `useState` hook with `useImmer` hook by importing at the top
57445744
3. The setter function of `useImmer` hook can be used to update the state.
57455745
5746-
For example, the mutation syntax of immer library simplies the nested address object of user state as follows,
5746+
For example, the mutation syntax of immer library simplifies the nested address object of user state as follows,
57475747
57485748
```jsx
57495749
import { useImmer } from "use-immer";
@@ -5762,7 +5762,7 @@ class ParentComponent extends React.Component {
57625762
});
57635763
```
57645764
5765-
The preceeding code enables you to update nested objects with a conceise mutation syntax.
5765+
The preceding code enables you to update nested objects with a conceise mutation syntax.
57665766
57675767
**[⬆ Back to Top](#table-of-contents)**
57685768

Diff for: coding-exercise/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function Counter() {
3232
<p>
3333

3434
##### Answer: 3
35-
State values are fixed(i.e, default value 5) in each render and setting the state only changes it for the next render. React will wait untill all the code executed with in an event handler before your state updates follwed by re-rendering the UI. Also, all the 3 setter function calls are replacing the calculated value. Hence, irrespective of how many times you call `setCounter(counter + 5)` the final value is 10(5+5).
35+
State values are fixed(i.e, default value 5) in each render and setting the state only changes it for the next render. React will wait until all the code executed with in an event handler before your state updates followed by re-rendering the UI. Also, all the 3 setter function calls are replacing the calculated value. Hence, irrespective of how many times you call `setCounter(counter + 5)` the final value is 10(5+5).
3636

3737
This can be visuallized by substituting with state variable values in the particular render,
3838
```javascript

0 commit comments

Comments
 (0)