Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrHoroshih committed Oct 31, 2023
1 parent ab054fb commit 4267173
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Sid's are added automatically via either built-in babel plugin or our experiment

### Effector ESlint Plugin

It is recommened to install the official [Effector ESlint Plugin](https://eslint.effector.dev/) with React Preset, it will help you follow best practices and avoid common mistakes
It is recommened to install the official [Effector ESlint Plugin](https://eslint.effector.dev/) with React Preset, it will help you follow best practices and avoid common mistakes, like always using `useUnit`

**.eslintrc**

Expand All @@ -48,6 +48,32 @@ It is recommened to install the official [Effector ESlint Plugin](https://eslint
}
```

#### Don't forget `useUnit` for all `effector` units

In SSR applications all of effector's units need to be "binded" to the current `Scope`, which means that you should always use `useUnit` in components:

```tsx
import { useUnit } from "effector-react"
import { eventTriggered, effectFx, $store } from "./model"

export function Component() {
const {
value,
trigger,
callEffect
} = useUnit({
value: $store,
trigger: eventTriggered,
callEffect: effectFx
})

// rest of the components code
}
```
You can find full docs about `useUnit` [here](https://effector.dev/docs/api/effector-react/useUnit).

The official [Effector ESlint Plugin](https://eslint.effector.dev/) with React Preset will help you to follow this rule.

### [Pages Router](https://nextjs.org/docs/pages/building-your-application/routing) usage

Before Next.js `13.4.0` Pages router was the main way to build Next.js applications.
Expand Down Expand Up @@ -148,31 +174,6 @@ You're all set. Just use effector's units anywhere in components code via `useUn

Also see the [`nextjs-effector`](https://github.com/risen228/nextjs-effector) package (_yeah, naming of the Next.js-related packages is kind of compicated_), which provides better DX to Pages Router usage and is built on top of the `@effector/next`.

#### Don't forget `useUnit` for all `effector` units

In SSR applications all of effector's units need to be "binded" to the current `Scope`, which means that you should always use `useUnit` in components:

```tsx
import { useUnit } from "effector-react"
import { eventTriggered, effectFx, $store } from "./model"

export function Component() {
const {
value,
trigger,
callEffect
} = useUnit({
value: $store,
trigger: eventTriggered,
callEffect: effectFx
})

// rest of the components code
}
```
You can find full docs about `useUnit` [here](https://effector.dev/docs/api/effector-react/useUnit).
Also there is the official [Effector ESlint Plugin](https://eslint.effector.dev/) with React Preset, which will help you to always use `useUnit`.

## [App Router](https://nextjs.org/docs/app/building-your-application/routing) usage

The App Router is a new paradigm for building Next.js applications using React's latest features, which declared stable since Next.js `13.4.0`.
Expand Down

0 comments on commit 4267173

Please sign in to comment.