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 Pluggables Framework Documentation #4948

Merged
merged 10 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions docs/source/recipes/pluggables.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ To understand how they work, it's useful to look at the architecture:
at `App.jsx` component level), so you don't have to do it:

```jsx
<PluggablesProvider>
...
</PluggablesProvider>
<PluggablesProvider>...</PluggablesProvider>
```

This `Provider` acts like a centralized place where "insertion points" and
Expand All @@ -47,7 +45,9 @@ Then we can plug things as children to the `<Pluggable>` with some `<Plug>`
components:

```jsx
<Plug pluggable="left-column" id="navigation">relevant nav stuff</Plug>
<Plug pluggable="left-column" id="navigation">
relevant nav stuff
</Plug>
```

Declaring a `<Plug>` with the same `id` twice will make the second one (in
Expand All @@ -57,16 +57,20 @@ Internally, the `<PluggablesProvider>` keeps a record of `Pluggables` and `Plug`
this is achieved by having the `<Pluggables>` and `<Plug>` components register
themselves with the Provider via React context.

```{note}
While Pluggables are a powerful framework for enhancing component integration, they are currently not compatible with server-side rendering (SSR).
They excel in providing dynamic visual enhancements for the user interface, such as client components and widgets.
However, when it comes to handling critical data that needs to load quickly, alternative approaches may be more suitable.
```
## Customize the rendering of plugs

You can customize the rendering of pluggables. The `<Pluggable>` component can take a function as a child and use that function to describe the rendering of pluggables.

```jsx
<Pluggable name="block-toolbar">
{(pluggables) => pluggables.map((p) => (<>{p()}</>))}
{(pluggables) => pluggables.map((p) => <>{p()}</>)}
</Pluggable>
```

## Passing parameters from the Pluggable to the Plugs

You can also pass options to the `Plugs`, to enable inter-component communication:
Expand All @@ -79,9 +83,9 @@ To use the passed params, you can do:

```jsx
<Plug pluggable="block-toolbar" id="style">
{({options}) => {
console.log(options);
return <Button>Click me</Button>
}}
{({ options }) => {
console.log(options);
return <Button>Click me</Button>;
}}
</Plug>
```
1 change: 1 addition & 0 deletions news/4735.documentation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added note that Pluggables are not compatible with server-side rendering (SSR). @Akshat2Jain
2 changes: 1 addition & 1 deletion news/4932.bugfix
stevepiercy marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Add a marker in the props passed to `RenderBlocks` in the Grid block view @sneridagh
Add a marker in the props passed to `RenderBlocks` in the Grid block view @sneridagh