Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat: support with Zustand 5 #16

Merged
merged 6 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: npm run build

- name: Upload Artifacts 🔼
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: site
path: example/dist
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Use the Broadcast Channel API in React easily with `hooks` or `Zustand`, and Typ
npm install use-broadcast-ts
```

This package allows you to use the Broadcast API with a simple hook or by using Zustand.
This package allows you to use the Broadcast API with a simple hook or by using Zustand v4/v5.

Checkout the [demo](https://romainlg29.github.io/use-broadcast/)!

Expand Down Expand Up @@ -39,15 +39,12 @@ const useStore = create<MyStore>(

// MyComponent.tsx
import { FC } from 'react';
import { useShallow } from 'zustand/shallow'

const MyComponent : FC = () => {

const { count, set } = useStore(
(s) => ({
count: s.count,
set: s.set
})
)
const count = useStore((s) => s.count);
const set = useStore((s) => s.set);

return (
<p>
Expand Down
43 changes: 23 additions & 20 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"use-broadcast-ts": "^1.4.3",
"zustand": "^4.5.0"
"use-broadcast-ts": "^1.8.0",
"zustand": "^5.0.0"
},
"devDependencies": {
"@types/react": "^18.0.37",
Expand Down
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const App = () => {
<div className="toast toast-top toast-start animate-in">
<div className="alert flex items-center justify-center">
<h1 className="font-semibold">use-broadcast-ts</h1>
<button className="btn btn-sm btn-neutral">v1.7.1</button>
<button className="btn btn-sm btn-neutral">v1.8.0</button>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion example/src/stores/useCountStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { create } from 'zustand';
import { shared } from 'use-broadcast-ts';
import { createWithEqualityFn as create } from 'zustand/traditional';

type CountStore = {
count: number;
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "use-broadcast-ts",
"version": "1.7.1",
"version": "1.8.0",
"description": "Use the Broadcast Channel API in React easily with hooks or Zustand, and Typescript!",
"type": "module",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -87,7 +87,7 @@
},
"homepage": "https://github.com/Romainlg29/use-broadcast",
"optionalDependencies": {
"zustand": "^4.0.0",
"zustand": "^4.0.0 || ^5.0.0",
"react": ">=18.0"
}
}
2 changes: 1 addition & 1 deletion src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const sharedImpl: SharedImpl = (f, options) => (set, get, store) => {
/**
* Update the states
*/
set(...args);
set(...(args as Parameters<typeof set>));

/**
* If the stores should not be synced, return.
Expand Down
Loading