fix: link to react documentation (#43704)

* Update set-state-with-this.setstate.md

revert the base url back to https://facebook.github.io/react/docs/state-and-lifecycle.html

* Update use-proptypes-to-define-the-props-you-expect.md

Linked to the exact place for the types of propTypes you can use. The original link was to the documentation, which states that it has been moved, So I thought it would be intuitive to link the exact place React wants you to go.

* Update curriculum/challenges/english/03-front-end-development-libraries/react/use-proptypes-to-define-the-props-you-expect.md

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>

* Update curriculum/challenges/english/03-front-end-development-libraries/react/set-state-with-this.setstate.md

Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
This commit is contained in:
Ngoako Ramokgopa
2021-10-05 01:51:29 +02:00
committed by GitHub
parent 4bfbb5e208
commit ce249f9625
2 changed files with 2 additions and 2 deletions

View File

@ -16,7 +16,7 @@ this.setState({
}); });
``` ```
React expects you to never modify `state` directly, instead always use `this.setState()` when state changes occur. Also, you should note that React may batch multiple state updates in order to improve performance. What this means is that state updates through the `setState` method can be asynchronous. There is an alternative syntax for the `setState` method which provides a way around this problem. This is rarely needed but it's good to keep it in mind! Please consult the [React documentation](https://facebook.github.io/react/docs/state-and-lifecycle.html) for further details. React expects you to never modify `state` directly, instead always use `this.setState()` when state changes occur. Also, you should note that React may batch multiple state updates in order to improve performance. What this means is that state updates through the `setState` method can be asynchronous. There is an alternative syntax for the `setState` method which provides a way around this problem. This is rarely needed but it's good to keep it in mind! Please consult the [React documentation](https://reactjs.org/docs/state-and-lifecycle.html#state-updates-may-be-asynchronous) for further details.
# --instructions-- # --instructions--

View File

@ -16,7 +16,7 @@ It's considered a best practice to set `propTypes` when you know the type of a p
MyComponent.propTypes = { handleClick: PropTypes.func.isRequired } MyComponent.propTypes = { handleClick: PropTypes.func.isRequired }
``` ```
In the example above, the `PropTypes.func` part checks that `handleClick` is a function. Adding `isRequired` tells React that `handleClick` is a required property for that component. You will see a warning if that prop isn't provided. Also notice that `func` represents `function`. Among the seven JavaScript primitive types, `function` and `boolean` (written as `bool`) are the only two that use unusual spelling. In addition to the primitive types, there are other types available. For example, you can check that a prop is a React element. Please refer to the [documentation](https://reactjs.org/docs/jsx-in-depth.html#specifying-the-react-element-type) for all of the options. In the example above, the `PropTypes.func` part checks that `handleClick` is a function. Adding `isRequired` tells React that `handleClick` is a required property for that component. You will see a warning if that prop isn't provided. Also notice that `func` represents `function`. Among the seven JavaScript primitive types, `function` and `boolean` (written as `bool`) are the only two that use unusual spelling. In addition to the primitive types, there are other types available. For example, you can check that a prop is a React element. Please refer to the [documentation](https://reactjs.org/docs/typechecking-with-proptypes.html#proptypes) for all of the options.
**Note:** As of React v15.5.0, `PropTypes` is imported independently from React, like this: `import PropTypes from 'prop-types';` **Note:** As of React v15.5.0, `PropTypes` is imported independently from React, like this: `import PropTypes from 'prop-types';`