{"_id":"zustand-context","_rev":"1-418646943b2a1ec457a93457fc73f414","name":"zustand-context","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.0":{"name":"zustand-context","version":"0.0.0","description":"Create react contexts with zustand","scripts":{"build":"tsup --dts --dts-resolve","test":"bun test src","check":"bunx @biomejs/biome check --apply ./src","release":"changeset publish"},"keywords":["react","reactjs","zustand","context","hooks"],"author":{"name":"fredericoo"},"main":"dist/index.js","types":"dist/index.d.ts","license":"MIT","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"devDependencies":{"@biomejs/biome":"1.7.1","@changesets/cli":"^2.27.1","@types/bun":"^1.1.0","@types/lodash":"^4.17.0","tsup":"^8.0.2","type-testing":"^0.2.0","typescript":"^5.4.5","zustand":"^4.5.2","@types/react":"^18.2.20","react":"^18.2.0"},"peerDependencies":{"zustand":">= 4","react":">= 18"},"_id":"zustand-context@0.0.0","gitHead":"2aaef2d9d0fccfc8df95fbe497db53256c088a26","_nodeVersion":"18.20.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-fT9uiFTxdNtpBTB/aXbaGGkCcrPpQr1nIlpT93qcD70nlWLbzlTkvLnkCFL6FkIanpZbjHPipl+yP16Znus+Xw==","shasum":"4051437ddc7dd68c76e31a9e5ef1f124153a5510","tarball":"https://registry.npmjs.org/zustand-context/-/zustand-context-0.0.0.tgz","fileCount":8,"unpackedSize":7538,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFO5EktTS+NHBIRUuf4hZzkDNiByKAqk46onKw4BTPNzAiAa2fkjRcfvFulM4isTAPNc3mUI+nrS5nfoTYoAomhqbQ=="}]},"_npmUser":{"name":"fredericoo","email":"rincofrederico@gmail.com"},"directories":{},"maintainers":[{"name":"fredericoo","email":"rincofrederico@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zustand-context_0.0.0_1714487789094_0.7453950472764432"},"_hasShrinkwrap":false},"1.0.0":{"name":"zustand-context","version":"1.0.0","description":"Create react contexts with zustand","scripts":{"build":"tsup --dts --dts-resolve","test":"bun test src","check":"bunx @biomejs/biome check --apply ./src","release":"changeset publish"},"keywords":["react","reactjs","zustand","context","hooks"],"author":{"name":"fredericoo"},"main":"dist/index.js","types":"dist/index.d.ts","license":"MIT","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"devDependencies":{"@biomejs/biome":"1.7.1","@changesets/cli":"^2.27.1","@types/bun":"^1.1.0","@types/lodash":"^4.17.0","tsup":"^8.0.2","type-testing":"^0.2.0","typescript":"^5.4.5","zustand":"^4.5.2","@types/react":"^18.2.20","react":"^18.2.0"},"peerDependencies":{"zustand":">= 4","react":">= 18"},"_id":"zustand-context@1.0.0","gitHead":"201a6dc20ac5cc2bc8ad659080a2efa96c26d688","_nodeVersion":"18.20.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-oWf9Gjp6xXOhTT4nP9Tau44IrHmNGqnQe/ftflBGPxWvOVS8NsKMns8PmGso2F37POk4rKngYxxe9viwFwbp1Q==","shasum":"b7cac043dbceeea2dd5dc39e8ae73762f8bc2e36","tarball":"https://registry.npmjs.org/zustand-context/-/zustand-context-1.0.0.tgz","fileCount":8,"unpackedSize":7556,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBo2DM9dqJvYQ2zzy7NFAfBlalrQoqhDhndmuIf3xawmAiAxD5So9JvQV1mtsWGy1Yc+e06TX8KTwlzGEM5YrW81kA=="}]},"_npmUser":{"name":"fredericoo","email":"rincofrederico@gmail.com"},"directories":{},"maintainers":[{"name":"fredericoo","email":"rincofrederico@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zustand-context_1.0.0_1714487875385_0.5187313664527482"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-30T14:36:28.987Z","0.0.0":"2024-04-30T14:36:29.288Z","modified":"2024-04-30T14:37:56.176Z","1.0.0":"2024-04-30T14:37:55.582Z"},"maintainers":[{"name":"fredericoo","email":"rincofrederico@gmail.com"}],"description":"Create react contexts with zustand","keywords":["react","reactjs","zustand","context","hooks"],"author":{"name":"fredericoo"},"license":"MIT","readme":"# Zustand Context\n\nZustand context is a **super tiny (281 bytes gzipped)** and easy way to create a context-aware zustand store. With this you may determine an initial value for your store and use it in your components with isolated instances.\n\n## Creating a Context-aware Zustand Store\n```ts\ntype Cat = string\n\ntype CatStore = {\n  cats: Cat[];\n  addCat: (cat: Cat) => void;\n  removeCat: (cat: Cat) => void;\n}\n\nexport const [CatsProvider, useCatsStore] = createZustandContext(\n\t(initialState: { cats: Cat[] }) =>\n\t\tcreate<CatStore>(set => ({\n\t\t\tcats: initialState.cats,\n\t\t\taddCat: cat => set(state => ({ cats: [...state.cats, cat] })),\n      removeCat: cat => set(state => ({ cats: state.cats.filter(c => c !== cat) })),\n\t\t})),\n);\n```\n\n## Consuming a Context-aware Zustand Store\n\n```tsx\nconst App = () => {\n  return <CatsProvider initialValue={{ cats: [\"Salem\", \"Mimo\", \"Tapi\"] }}>\n    <CatsList />\n  </CatsProvider>\n}\n\nconst CatsList = () => {\n  /** Exact same api as zustand */\n  const cats = useCatsStore(state => state.cats);\n\n  return <ul>\n    {cats.map(cat => <li key={cat}>{cat}</li>)}\n  </ul>\n}\n```\n\n## Contributing\n\nThis project is open to contributions. Feel free to open an issue or a pull request.\n\n## License\n\nMIT","readmeFilename":"readme.md"}