React Native

Hello, I am making a react native app. Can someone please point me in the right direction? I am making a signup screen that has several different screens that I will need to get info from in the signup process before creating that user. Is this a good use case for useContext?
3 Replies
haru_nonak
haru_nonak3mo ago
Yes, there is a use case for useContext because the thing is, you need login information throughout the entire app. However, you can't pass it with props to all components. The basic idea is to create a global store with useContext or use Redux, so that instead of passing the login state through props, you can access it from anywhere in the app.
Ayoub K
Ayoub K3mo ago
Don't use redux, use something simpler, use Zustand. You can also use the context but it will be a bit messy.
henry
henry7d ago
It might depend a bit on how you're doing Auth in your app. I'm using Supabase Auth in mine, and I have a context for managing strictly auth-related things (Session, Role, login/logout handlers, etc.). Separately I have user data that I fetch from joining a number of tables, and need to make available in a handful of places. I'm managing that with TanStack/React Query. Haven't had cause to reach for Zustand yet, but that's because most of the data in my app is remote data from Supabase, which is better handled through an Async state management library like TanStack Query. If your app has a lot of local data that you don't need to store in or fetch from a DB or server somewhere, Zustand is probably a good choice.
Want results from more Discord servers?
Add your server