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: add zustand #41

Merged
merged 2 commits into from
Jan 9, 2025
Merged
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
31 changes: 30 additions & 1 deletion package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@
"prepare": "husky"
},
"dependencies": {
"@radix-ui/react-avatar": "^1.1.2",
"@hookform/resolvers": "^3.10.0",
"@radix-ui/react-avatar": "^1.1.2",
"@radix-ui/react-slot": "^1.1.1",
"axios": "^1.7.9",
"class-variance-authority": "^0.7.1",
@@ -29,7 +29,8 @@
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"tailwindcss-animated": "^1.1.2",
"yup": "^1.6.1"
"yup": "^1.6.1",
"zustand": "^5.0.3"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
16 changes: 16 additions & 0 deletions src/lib/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// global store/state

import { create } from "zustand";

export interface IStore {
count: number;
setCount: (value: number) => void;
}

export const useStore = create<IStore>(set => ({
count: 0,
setCount: value => set(() => ({ count: value })),
}));

// Example:
// const { count, setCount } = useStore();
2 changes: 1 addition & 1 deletion src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
path: "/set-username",
element: <SetUserName />,
},
{
{

Check warning on line 26 in src/routes/index.tsx

GitHub Actions / Linting

Delete `·`
path: "/payment-result",
element: <PaymentResult />,
},

Unchanged files with check annotations Beta

if (dimensions.width && dimensions.height) {
setSquares(generateSquares(numSquares));
}
}, [dimensions, numSquares]);

Check warning on line 74 in src/components/ui/animated-grid-pattern.tsx

GitHub Actions / Linting

React Hook useEffect has a missing dependency: 'generateSquares'. Either include it or remove the dependency array
// Resize observer to update container dimensions
useEffect(() => {
return () => {
if (containerRef.current) {
resizeObserver.unobserve(containerRef.current);

Check warning on line 93 in src/components/ui/animated-grid-pattern.tsx

GitHub Actions / Linting

The ref value 'containerRef.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy 'containerRef.current' to a variable inside the effect, and use that variable in the cleanup function
}
};
}, [containerRef]);