Skip to content

How to use Model/State in TextInput in React Native #1894

Answered by EmilTholin
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @jojemapa!

To access your RootStoreModel instance you can use the useStores hook and then use the property you named userStore to access your user.

export const SignInScreen: FC<StackScreenProps<NavigatorParamList, "signIn">> =
  observer(({ navigation }) => {
    const { userStore } = useStores();

    return (
      <Screen style={ROOT} preset="scroll">
        <Text text={"Username: " + userStore.username} />

        <TextInput
          value={userStore.username}
          onChangeText={(value) => {
            userStore.setUsername(value);
          }}
        />
      </Screen>
    );
  });

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ghost
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant