Skip to content

Commit 1b66679

Browse files
vktrlbirtles
authored andcommitted
add react decorator example
1 parent 578ac56 commit 1b66679

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ wraps everything in the `DarkMode` fixture.
4747
You can do that by adding a file named `cosmos.decorator.tsx` to your root `src`
4848
folder that looks something like this:
4949

50+
### React
51+
52+
```ts
53+
// "use client" if you're using Next.js
54+
import * as React from 'react';
55+
import { DarkMode } from 'react-cosmos-dark-mode/DarkMode';
56+
57+
export default function GlobalDecorator(props: { children: React.ReactNode }) {
58+
return <DarkMode {...props} />;
59+
}
60+
```
61+
62+
### Preact
63+
5064
```ts
5165
import type { RenderableProps } from 'preact';
5266
import { DarkMode } from 'react-cosmos-dark-mode/DarkMode';
@@ -60,8 +74,6 @@ export default function GlobalDecorator({
6074
}
6175
```
6276

63-
(Can someone please help me update this for React?)
64-
6577
## Configuration
6678

6779
The following configuration options can be set in the `ui.darkMode` section of

0 commit comments

Comments
 (0)