Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Steve Piercy <[email protected]>
  • Loading branch information
sneridagh and stevepiercy authored Oct 17, 2024
1 parent a9802d2 commit fb339b4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/client/news/6069.internal
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Upgrade @tanstack/react-query @sneridagh
Upgrade `@tanstack/react-query`. @sneridagh
8 changes: 4 additions & 4 deletions packages/components/news/6069.breaking
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Removed the `FlattenToAppURLProvider` since is no longer needed @sneridagh
The components in here are meant to to need it.
Refactored the `Link` component to not use it since `react-aria-components` use the React Client Routing facilities that can be injected in the React tree.
Removed the `FlattenToAppURLProvider` since it's no longer needed. @sneridagh
The components in here need it.
Refactored the `Link` component to not use it, since `react-aria-components` uses the React Client Routing facilities that can be injected into the React tree.

Breaking:
- Use the new providers in @plone/providers instead to make the new Link work with them
- Use the new providers in `@plone/providers` instead to make the new `Link` work with them.
29 changes: 17 additions & 12 deletions packages/providers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This package contains utility providers for Plone React components.
The main purpose is to provide dependency injection of common required artifacts needed by any app.
This artifacts are:
These artifacts include:
- Router related
- Plone Client
- URL handling methods
Expand All @@ -28,7 +28,7 @@ interface PloneProvider {
}
```

It should be instantated at the top of your app.
It should be instantiated at the top of your app.
You have to provide the required props depending on the framework and the router used.
This is the example for a Next.js app.
Please refer to the {file}`apps` folder of the Volto repository for more examples of the usage of `PloneProvider` in different React frameworks.
Expand Down Expand Up @@ -115,25 +115,28 @@ export default Providers;

```

You can use anywhere in your app by using the hook `usePloneProvider`.
You can use it anywhere in your app by using the hook `usePloneProvider`.

```tsx
import { usePloneProvider } from '@plone/providers';

const { ploneClient } = usePloneProvider()
```

or any other context property.
Alternatively, you can use it in any other context property.

```tsx
const { navigate } = usePloneProvider()
```

### `PloneClientProvider`
## `PloneClientProvider`

`PloneProvider` in a group of other smaller providers.
In case you need them separatedly, you can also instantiate and use them standalone.
However, only do this is the framework has some limitation on using the bulk `PloneClientProvider`.
You can also instantiate and use them as standalone providers.
However, you should do this only if the framework has some limitation on using the bulk `PloneClientProvider`.

The following snippets show its usage.
First, instantiate the provider.

```ts
export type PloneClientProviderProps = {
Expand All @@ -143,7 +146,7 @@ export type PloneClientProviderProps = {
};
```

and the related hook:
Second, use its related hook through the following example.

```tsx
import { usePloneClient } from '@plone/providers';
Expand All @@ -157,11 +160,13 @@ or
const { getContentQuery } = usePloneClient()
```

### `AppRouterProvider`
## `AppRouterProvider`

This provider is included also in `PloneProvider`.
In case you need it separatedly, you can also instantiate and use it standalone.
However, only do this is the framework has some limitation on using the bulk `PloneClientProvider`.
You can also instantiate and use it as a standalone provider.
However, you should do this only if the framework has some limitation on using the bulk `PloneClientProvider`.

The following code example shows its usage.

```ts
interface AppRouterProps {
Expand All @@ -174,7 +179,7 @@ interface AppRouterProps {
}
```

and the related hook:
The following code sample shows its related hook.

```tsx
import { useAppRouter } from '@plone/providers';
Expand Down

0 comments on commit fb339b4

Please sign in to comment.