Skip to content

Commit

Permalink
fix diff
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Jun 4, 2024
1 parent 78794ae commit d23e386
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
23 changes: 8 additions & 15 deletions .changeset/fair-singers-reflect.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,20 @@

The integration now exposes a function called `getContainerRenderer`, that can be used inside the Container APIs to load the relative renderer.

```diff
```js
import { experimental_AstroContainer as AstroContainer } from 'astro/container';
import ReactWrapper from '../src/components/ReactWrapper.astro';
import { loadRenderers } from "astro:container";
import { getContainerRenderer } from "@astrojs/react";

test('ReactWrapper with react renderer', async () => {
+ const renderers = await loadRenderers([getContainerRenderer()])
- const renderers = [
- {
- name: '@astrojs/react',
- clientEntrypoint: '@astrojs/react/client.js',
- serverEntrypoint: '@astrojs/react/server.js',
- },
- ];
const container = await AstroContainer.create({
renderers,
});
const result = await container.renderToString(ReactWrapper);
const renderers = await loadRenderers([getContainerRenderer()])
const container = await AstroContainer.create({
renderers,
});
const result = await container.renderToString(ReactWrapper);

expect(result).toContain('Counter');
expect(result).toContain('Count: <!-- -->5');
expect(result).toContain('Counter');
expect(result).toContain('Count: <!-- -->5');
});
```
23 changes: 15 additions & 8 deletions .changeset/gold-mayflies-beam.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,28 @@ Changes the **type** of the `renderers` option of the `AstroContainer::create` f

You no longer need to know the individual, direct file paths to the client and server rendering scripts for each renderer integration package. Now, there is a dedicated function to load the renderer from each package, which is available from `getContainerRenderer()`:

```js
```diff
import { experimental_AstroContainer as AstroContainer } from 'astro/container';
import ReactWrapper from '../src/components/ReactWrapper.astro';
import { loadRenderers } from "astro:container";
import { getContainerRenderer } from "@astrojs/react";

test('ReactWrapper with react renderer', async () => {
const renderers = await loadRenderers([getContainerRenderer()])
const container = await AstroContainer.create({
renderers,
});
const result = await container.renderToString(ReactWrapper);
+ const renderers = await loadRenderers([getContainerRenderer()])
- const renderers = [
- {
- name: '@astrojs/react',
- clientEntrypoint: '@astrojs/react/client.js',
- serverEntrypoint: '@astrojs/react/server.js',
- },
- ];
const container = await AstroContainer.create({
renderers,
});
const result = await container.renderToString(ReactWrapper);

expect(result).toContain('Counter');
expect(result).toContain('Count: <!-- -->5');
expect(result).toContain('Counter');
expect(result).toContain('Count: <!-- -->5');
});
```

Expand Down

0 comments on commit d23e386

Please sign in to comment.