Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update react reference links in package's readme and doc blocks #62704

Merged
merged 8 commits into from
Jul 17, 2024
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Block Context

Block Context is a React implementation of WordPress's block context. Block context, much like [React's context](https://reactjs.org/docs/context.html), is a method for passing and inheriting values deeply through a hierarchy of blocks. Because of the similarities with React's context, the client-side implementation here is quite minimal. It is complemented by equivalent behaviors in the server-side rendering of a block.
Block Context is a React implementation of WordPress's block context. Block context, much like [React's context](https://react.dev/learn/passing-data-deeply-with-context), is a method for passing and inheriting values deeply through a hierarchy of blocks. Because of the similarities with React's context, the client-side implementation here is quite minimal. It is complemented by equivalent behaviors in the server-side rendering of a block.

Note that the implementation of Block Context is distinct from [the `BlockEdit` context](../block-edit). While it is true that both provide context relevant for the editing of a block, Block Context is implemented separately so as to prioritize it as most identifiable amongst the machinery of block context, and not amongst other client-side editing context of a block.

## Usage

Currently, only the [Provider component](https://reactjs.org/docs/context.html#contextprovider) is made available on the public interface of the `@wordpress/block-editor` module. This can be used to add or override context which can then be consumed by blocks rendered within that context in the block editor.
Currently, only the [Provider component](https://react.dev/reference/react/createContext#provider) is made available on the public interface of the `@wordpress/block-editor` module. This can be used to add or override context which can then be consumed by blocks rendered within that context in the block editor.

```js
import { BlockContextProvider } from '@wordpress/block-editor';
Expand All @@ -20,7 +20,7 @@ function MyCustomPostEditor() {
}
```

Internal to the `@wordpress/block-editor` module, a component can access the [full Context object](https://reactjs.org/docs/context.html#api), typically for use in combination with [`useContext`](https://reactjs.org/docs/hooks-reference.html#usecontext).
Internal to the `@wordpress/block-editor` module, a component can access the [full Context object](https://react.dev/reference/react/createContext), typically for use in combination with [`useContext`](https://react.dev/reference/react/useContext).

```js
import { useContext } from 'react';
Expand All @@ -39,7 +39,7 @@ The reason `BlockContext` is only internally available within the `@wordpress/bl

## Props

`BlockContextProvider` behaves like a standard [`Context.Provider` component](https://reactjs.org/docs/context.html#contextprovider). It receives `value` and `children` props. The `value` is merged with the current block context value.
`BlockContextProvider` behaves like a standard [`Context.Provider` component](https://react.dev/reference/react/createContext#provider). It receives `value` and `children` props. The `value` is merged with the current block context value.

### `value`

Expand Down
2 changes: 1 addition & 1 deletion packages/components/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ Not all style changes justify a formal deprecation process. The main thing to lo

## Context system

The `@wordpress/components` context system is based on [React's `Context` API](https://reactjs.org/docs/context.html), and is a way for components to adapt to the "context" they're being rendered in.
The `@wordpress/components` context system is based on [React's `Context` API](https://react.dev/reference/react/createContext), and is a way for components to adapt to the "context" they're being rendered in.

Components can use this system via a couple of functions:

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/card/card/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const Example = () => (

### Context

`<Card />`'s sub-components are connected to `<Card />` using [Context](https://reactjs.org/docs/context.html). Certain props like `size` and `isBorderless` are passed through to some of the sub-components.
`<Card />`'s sub-components are connected to `<Card />` using [Context](https://react.dev/learn/passing-data-deeply-with-context). Certain props like `size` and `isBorderless` are passed through to some of the sub-components.

In the following example, the `<CardBody />` will render with a size of `small`:

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/disabled/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const MyDisabled = () => {
};
```

A component can detect if it has been wrapped in a `<Disabled />` by accessing its [context](https://reactjs.org/docs/context.html) using `Disabled.Context`.
A component can detect if it has been wrapped in a `<Disabled />` by accessing its [context](https://react.dev/learn/passing-data-deeply-with-context) using `Disabled.Context`.

```jsx
function CustomButton( props ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const BottomSheetNavigationScreen = ( {
* passed to useCallback here is what prevents erroneous callback
* replacements, but leveraging memoization to achieve this is brittle and
* explicitly discouraged in the React documentation.
* https://reactjs.org/docs/hooks-reference.html#usememo
* https://react.dev/reference/react/useMemo
*
* Ideally, we refactor onHandleHardwareButtonPress to manage multiple
* callbacks triggered based upon which screen is currently active.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Determines if the label can render.

### labelRef

Callback [Ref](https://reactjs.org/docs/forwarding-refs.html) for the label element.
Callback [Ref](https://react.dev/learn/manipulating-the-dom-with-refs) for the label element.

- Type: `Function`
- Required: No
Expand Down
4 changes: 2 additions & 2 deletions packages/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ _Returns_

A custom react Context consumer exposing the provided `registry` to children components. Used along with the RegistryProvider.

You can read more about the react context api here: <https://reactjs.org/docs/context.html#contextprovider>
You can read more about the react context api here: <https://react.dev/learn/passing-data-deeply-with-context#step-3-provide-the-context>

_Usage_

Expand Down Expand Up @@ -796,7 +796,7 @@ _Returns_

Custom react hook for retrieving props from registered selectors.

In general, this custom React hook follows the [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
In general, this custom React hook follows the [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).

_Usage_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { Consumer, Provider } = Context;
* children components. Used along with the RegistryProvider.
*
* You can read more about the react context api here:
* https://reactjs.org/docs/context.html#contextprovider
* https://react.dev/learn/passing-data-deeply-with-context#step-3-provide-the-context
*
* @example
* ```js
Expand Down
2 changes: 1 addition & 1 deletion packages/data/src/components/use-select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ function useMappingSelect( suspense, mapSelect, deps ) {
* Custom react hook for retrieving props from registered selectors.
*
* In general, this custom React hook follows the
* [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
* [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).
*
* @template {MapSelect | StoreDescriptor<any>} T
* @param {T} mapSelect Function called on every state change. The returned value is
Expand Down
2 changes: 1 addition & 1 deletion packages/element/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ _Related_

_Related_

- <https://reactjs.org/docs/hooks-reference.html#useeffect>
- <https://react.dev/reference/react/useEffect>

### useId

Expand Down
2 changes: 1 addition & 1 deletion packages/element/src/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export { useDebugValue };
export { useDeferredValue };

/**
* @see https://reactjs.org/docs/hooks-reference.html#useeffect
* @see https://react.dev/reference/react/useEffect
*/
export { useEffect };

Expand Down
Loading