Skip to content

Commit

Permalink
docs(readme): update
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Dec 17, 2024
1 parent 6e46365 commit 78acb26
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ npm install coaction
```jsx
import { create } from '@coaction/react';

const useStore = create((set, get) => ({
const useStore = create((set) => ({
count: 0,
increment: () => set((state) => state.count++)
}));
Expand All @@ -161,8 +161,6 @@ const CounterComponent = () => {
`counter.js`:

```js
import { create } from '@coaction/react';

export const counter = (set) => ({
count: 0,
increment: () => set((state) => state.count++)
Expand All @@ -175,21 +173,24 @@ export const counter = (set) => ({
import { create } from '@coaction/react';
import { counter } from './counter';

const useStore = create(counter);
create(counter);
```

```jsx
import { create } from '@coaction/react';
import { counter } from './counter';

const worker = new Worker(new URL('./worker.js', import.meta.url));
const worker = new Worker(new URL('./worker.js', import.meta.url), {
type: 'module'
});
const useStore = create(counter, { worker });

const CounterComponent = () => {
const store = useStore();
return (
<div>
<p>Count in Worker: {store.count}</p>
<button onClick={store.increment}>Increment</button>
<button onClick={() => store.increment()}>Increment</button>
</div>
);
};
Expand Down

0 comments on commit 78acb26

Please sign in to comment.