dorian.naa
dorian.naa

Reputation: 156

React Native : Have a different home screen for new users and older users

I'm quite new to react native and I'm developing my first scenes / screens.

A question that I'm asking myself right now is : How to

If anyone could provide me some documentation or references on how to achieve that, that would help me a lot.

Thanks !

Upvotes: 0

Views: 210

Answers (1)

DavidP
DavidP

Reputation: 2048

You did not specify your navigation library, but the concept is similar to a standard auth flow. Show login if not authed, or show the app if indeed authenticated.

More detail and explanation here.

You can as a very basic method store a locally stored key-value to state that the user has "onboarded" (thus a returning "old" user). Any device without this key-value pair would then be shown the "new user" screen, while any device that have this will see the "returning user" screen. You can achieve this using the example above:

const { onboarded } = useLocalStorage('onboarded') // You will need to write this logic

onboarded ? (
  <Stack.Screen name="ReturningHome" component={ReturningUserHomeScreen} />
) : (
  <Stack.Screen name="NewHome" component={NewUserHomeScreen} />
)

Upvotes: 1

Related Questions