Skip to content

Commit

Permalink
GH-6 Adds "use client" directive to prevent errors when using React S…
Browse files Browse the repository at this point in the history
…erver Components (#7)

Closes #6
  • Loading branch information
traviswimer authored Nov 15, 2023
1 parent 9fcfa8f commit 69b6aec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ const {
} = require("react-hydration-provider");
```

### Usage with Server Components

_Requires `react-hydration-provider` version 2.1.0 or later_

If you are using [React Server Components](https://react.dev/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023#react-server-components), you should be able to use `HydrationProvider` and it's corresponding hooks/components without any changes.

If you are using the standalone `useComponentHydrated` hook, you will need to include the [`"use client";`](https://react.dev/reference/react/use-client) directive in any component that uses it.

<h3 id="examples">Usage examples</h3>

**Basic Example**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-hydration-provider",
"version": "2.0.0",
"version": "2.1.0",
"license": "MIT",
"type": "module",
"description": "React tools for controlling what your app renders before and after app hydration.",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import createHydration, { useComponentHydrated } from "./createHydration.js";

const { HydrationContext, HydrationProvider, useHydrated, Server, Client } =
Expand Down

0 comments on commit 69b6aec

Please sign in to comment.