Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrHoroshih committed Feb 14, 2024
1 parent 61c1de4 commit c7ae644
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Start your computations via Fork API and use `scope.getState` to extract data fr

It should be noted, that `getState` usage is typically undesirable in production code - except for the cases when you need to connect effector with some external thing or api, which is exactly the case with Next.js here.

**`generateStaticParams` example**
##### `generateStaticParams` example

[See relevant Next.js docs for API details](https://nextjs.org/docs/app/api-reference/functions/generate-static-params)

Expand Down Expand Up @@ -285,7 +285,7 @@ export default async function Page({ params }: { params: { slug: string } }) {
}
```

**`notFound` and `redirect` example**
##### `notFound` and `redirect` example

There are few special functions, which, when called from inside of an server component, will throw a special exception, which will command Next.js to perform redirect somewhere.
The `notFound` function will redirect to `notFound.tsx` view for a current page.
Expand Down Expand Up @@ -323,7 +323,7 @@ export default async function Page({ params }: { params: { slug: string } }) {
```
☝️ It works the same for any other of Next.js special functions: if you need to access the store value outside of client components, you will need to use `scope.getState`.

**Server Actions example**
##### `Server Actions` example

1. Server actions must be created [as usual](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations).

Expand All @@ -347,6 +347,8 @@ const myActionFx = createEffect(myAction)

That's it.

See [`apps/playground-app/src/features/server-action`](https://github.com/effector/next/tree/main/apps/playground-app/src/features/server-action) for live example.

#### Don't forget about `use client` for client components:

Just [write effector's models as usual](https://effector.dev/) and use effector's units anywhere in components code [via `useUnit` from `effector-react`](https://effector.dev/docs/api/effector-react/useUnit) - but don't forget, that to use hooks you need the `"use client"` directive.
Expand Down

0 comments on commit c7ae644

Please sign in to comment.