Home > Enterprise >  Is there a way to use dynamic variables in React or React Native
Is there a way to use dynamic variables in React or React Native

Time:11-19

GUEST_1 is a variable. I need to be able to change the number on the end dynamically and it would represent my variable. Is there any way to do this: currently I get GUEST_gestNumber not defined. There is different text that I get from this example GUEST_1 GUEST_2 GUEST_3

  const guest = (guestNumber) => {
    return (
      <View>
        <Text>{GUEST_guestNumber}</Text>
      </View>
    );
  };

CodePudding user response:

is this what you want?

  const guest = (guestNumber) => {
    return (
      <View>
        <Text>{'GUEST_'   guestNumber}</Text>
      </View>
    );
  };

if not, your question is very unclear.

  • Related