diff --git a/snippets/CountDown.md b/snippets/CountDown.md index f7fce6729..96c4c2772 100644 --- a/snippets/CountDown.md +++ b/snippets/CountDown.md @@ -5,71 +5,51 @@ tags: components,state,advanced Renders a countdown timer that prints a message when it reaches zero. -- Use object destructuring to set defaults for the `hours`, `minutes` and `seconds` props. -- Use the `React.useState()` hook to create the `time`, `paused` and `over` state variables and set their values to the values of the passed props, `false` and `false` respectively. -- Create a method `tick`, that updates the value of `time` based on the current value (i.e. decreasing the time by one second). -- If `paused` or `over` is `true`, `tick` will return immediately. +- Use the `useState()` hook to create a state variable to hold the time value, initialize it from the props and destructure it into its components. +- Use the `useState()` hook to create the `paused` and `over` state variables, used to prevent the timer from ticking if it's paused or the time has run out. +- Create a method `tick`, that updates the time values based on the current value (i.e. decreasing the time by one second). - Create a method `reset`, that resets all state variables to their initial states. -- Use the the `React.useEffect()` hook to call the `tick` method every second via the use of `setInterval()` and use `clearInterval()` to cleanup when the component is unmounted. -- Use a `
` to wrap a `

` element with the textual representation of the components `time` state variable, as well as two ` +

); @@ -77,5 +57,8 @@ const CountDown = ({ hours = 0, minutes = 0, seconds = 0 }) => { ``` ```jsx -ReactDOM.render(, document.getElementById('root')); +ReactDOM.render( + , + document.getElementById('root') +); ``` diff --git a/snippets/MultiselectCheckbox.md b/snippets/MultiselectCheckbox.md index 28419db29..7aa325ab7 100644 --- a/snippets/MultiselectCheckbox.md +++ b/snippets/MultiselectCheckbox.md @@ -5,45 +5,38 @@ tags: components,input,state,array,intermediate Renders a checkbox list that uses a callback function to pass its selected value/values to the parent component. -- Use `React.useState()` to create a `data` state variable and set its initial value equal to the `options` prop. -- Create a function `toggle` that is used to toggle the `checked` to update the `data` state variable and call the `onChange` callback passed via the component's props. -- Render a `