Skip to content

Commit 2024b06

Browse files
Update index.md
Дополнил в описании пару фраз и небольшой пример использования на react
1 parent 8e39331 commit 2024b06

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

apps/website/docs/factories/index.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,29 @@ const createCounter = createFactory(({ initialValue }) => {
9898
### `invoke`
9999

100100
Anywhere in your application you can invoke a factory by calling `invoke` with a factory and its arguments:
101+
We do not call `invoke` in components; instead, we call it in **`.js`** or **`.ts`** files, as if we were writing regular Effector code.
101102

102-
```ts
103+
```js
103104
import { invoke } from '@withease/factories';
104105

105-
const counter = invoke(createCounter, { initialValue: 2 });
106+
const { $counter, increment, decrement } = invoke(createCounter, { initialValue: 2 });
107+
```
108+
109+
Now we can use `$counter`, `increment`, and `decrement` in our components
110+
Here’s how you might use them in a React component:
111+
112+
```jsx
113+
const CounterComponent = () => {
114+
const counter = useStore($counter);
115+
116+
return (
117+
<div>
118+
<p>Counter: {counter}</p>
119+
<button onClick={() => increment()}>Increment</button>
120+
<button onClick={() => decrement()}>Decrement</button>
121+
</div>
122+
);
123+
};
106124
```
107125

108126
::: warning

0 commit comments

Comments
 (0)