Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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>
    );
  };

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

is this what you want?

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

if not, your question is very unclear.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading