kgni
kgni
Explore posts from servers
TTCTheo's Typesafe Cult
Created by kgni on 2/9/2024 in #questions
Zustand persist individual slices (zustand-x library instead?)
Hi guys! Anyone used this 3rd party abstraction of Zustand? I want to know if I might be running into any pitfalls https://github.com/udecode/zustand-x An issue I have with the base Zustand library is with persisting only specific slices in my global store. To accomplish this I have to either create a separate store or use the partialize function which seems very boilerplatey and annoying to work with on a bigger scale (I might be wrong here, this is just what I'm getting from the documentation) However with the zustand-x library (formerly known as zustood), a lot of boilerplate is removed, and you can persist individual stores. Example (pay attention that you don't need to create getters or setters when writing your stores either - but you can extend both the selectors and actions on the store if you need to):
export const authStore = createStore('auth')(
{
session: undefined,
user: undefined,
},
{
persist: {
name: 'auth',
storage: createJSONStorage(() => zustandStorage),
},
},
);
export const authStore = createStore('auth')(
{
session: undefined,
user: undefined,
},
{
persist: {
name: 'auth',
storage: createJSONStorage(() => zustandStorage),
},
},
);
2 replies
TTCTheo's Typesafe Cult
Created by kgni on 2/4/2024 in #questions
monorepo (turborepo) importing specific files depending on platform
Hi there. I have a monorepo with a Next and a React Native application. I have a shared file that contains all of the same providers used in both apps. let's say one of the specific providers have to be set up in two different ways depending on if it is used for web or native. How would I accomplish this the best way, given that I would still want to use a shared file containing all providers? Is it possible to add on an extension for web like specificProvider.web.tsx and then this file is used for the import only on web (while the normal native specificProvider.tsx is imported on native)? So the import would be something like: '@providers/specificProvider' but it is essentially imported from 2 different environments depending on the platform. Cheers
2 replies
TTCTheo's Typesafe Cult
Created by kgni on 1/22/2024 in #questions
create-t3-turbo issues
Hi guys, I just started diving into the create-t3-turbo monorepo. Unfortunately I'm facing some quite annoying issues setting up and running the base template. I'm following the readme and can get both apps to run with some tricks - however I was expecting it to work out of the box - and I'm not sure if it is my setup there is something wrong with. Setup: Apple M1 Pro macOS: Sonoma 14.2.1 package manager: pnpm (tried installing this several different ways) - tried every package manager and I'm facing the same issues for every one of them Issues I'm facing (I will post more info below): 1. permission denied, open - for certain files in the expo directory. Happens for the auto generated .gitignore file (can't even open it manually) - running with sudo works. Tried various recommendations online (like chmod, deleting and reinstalling the package managers etc) 2. hot reloading for the Nextjs app is quite slow (600ms - 1s to recompile), longer to appear in the browser - is this to be expected? (am I just being a brat? 🙂 ) 3. hot reloading not working in expo at all (not sure if this is can be related to issue 1) I know it can be difficult to remotely debug stuff like this, I'm at a point where I would love to give away a bounty if someone can help me out (hopefully this doesn't break any TOS 😅 ) Sorry in advance for this noob question
17 replies