Fix typos
This commit is contained in:
@ -9,7 +9,7 @@ Renders an accordion menu with multiple collapsible content elements.
|
||||
- Use the `isCollapsed` prop in `AccordionItem` to determine its appearance and set an appropriate `className`.
|
||||
- Define an `Accordion` component that uses the `useState()` hook to initialize the value of the `bindIndex` state variable to `defaultIndex`.
|
||||
- Filter `children` to remove unnecessary nodes except for `AccordionItem` by identifying the function's name.
|
||||
- Use `Array.prototype.map()` on the collected nodes to render the individual collapsiple elements.
|
||||
- Use `Array.prototype.map()` on the collected nodes to render the individual collapsible elements.
|
||||
- Define `changeItem`, which will be executed when clicking an `AccordionItem`'s `<button>`.
|
||||
- `changeItem` executes the passed callback, `onItemClick`, and updates `bindIndex` based on the clicked element.
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ tags: components,state,effect,beginner
|
||||
|
||||
Renders an alert component with `type` prop.
|
||||
|
||||
- Use the `useState()` hook to create the `isShown` and `isLeaving` state variables and set both to `false` intially.
|
||||
- Use the `useState()` hook to create the `isShown` and `isLeaving` state variables and set both to `false` initially.
|
||||
- Define `timeoutId` to keep the timer instance for clearing on component unmount.
|
||||
- Use the `useEffect()` hook to update the value of `isShown` to `true` and clear the interval by using `timeoutId` when the component is unmounted.
|
||||
- Define a `closeAlert` function to set the component as removed from the DOM by displaying a fading out animation and set `isShown` to `false` via `setTimeout()`.
|
||||
|
||||
@ -8,7 +8,7 @@ Renders a textarea component with a word limit.
|
||||
- Use the `useState()` hook to create a state variable, containing `content` and `wordCount`, using the `value` prop and `0` as the initial values respectively.
|
||||
- Use the `useCallback()` hooks to create a memoized function, `setFormattedContent`, that uses `String.prototype.split()` to turn the input into an array of words.
|
||||
- Check if the result of applying `Array.prototype.filter()` combined with `Boolean` has a `length` longer than `limit` and, if so, trim the input, otherwise return the raw input, updating state accordingly in both cases.
|
||||
- Use the `useEffect()` hook to call the `setFormattedContent` method on the value of the `content` state variable during the inital render.
|
||||
- Use the `useEffect()` hook to call the `setFormattedContent` method on the value of the `content` state variable during the initial render.
|
||||
- Bind the `onChange` event of the `<textarea>` to call `setFormattedContent` with the value of `event.target.value`.
|
||||
|
||||
```jsx
|
||||
|
||||
@ -9,7 +9,7 @@ Handles asynchronous calls.
|
||||
- Define a reducer function and an initial state for the custom hook's state.
|
||||
- Use the `useReducer()` hook to initialize the `state` variable and the `dispatch` function.
|
||||
- Define an asynchronous `run` function that will run the provided callback, `fn`, while using `dispatch` to update `state` as necessary.
|
||||
- Return an object containting the properties of `state` (`value`, `error` and `loading`) and the `run` function.
|
||||
- Return an object containing the properties of `state` (`value`, `error` and `loading`) and the `run` function.
|
||||
|
||||
```jsx
|
||||
const useAsync = fn => {
|
||||
|
||||
@ -7,8 +7,8 @@ Implements `fetch` in a declarative manner.
|
||||
|
||||
- Create a custom hook that takes a `url` and `options`.
|
||||
- Use the `useState()` hook to initialize the `response` and `error` state variables.
|
||||
- Use the `useEffect()` hook to anychronously call `fetch()` and update the state variables accordingly.
|
||||
- Return an object containting the `response` and `error` state variables.
|
||||
- Use the `useEffect()` hook to asynchronously call `fetch()` and update the state variables accordingly.
|
||||
- Return an object containing the `response` and `error` state variables.
|
||||
|
||||
```jsx
|
||||
const useFetch = (url, options) => {
|
||||
|
||||
Reference in New Issue
Block a user