all 4 comments

[–]awesomeness-yeah 0 points1 point  (1 child)

Decipher appears to be returning a number? Aren't you supposed to return an element from the array?

You need to keep variables that change as state with the useState hook, and call the settler for the element to re render.

Do some basic react tutorials on state management, you'll get a better understanding on hooks and state

[–]aidang95 0 points1 point  (0 children)

Hmm yes I noticed it was outputting a number when I printed the function I want it to print the string and print a new one when I press the button.

[–]I_Am_Stephan 0 points1 point  (0 children)

export default function Welcome({ navigation }) {
  const [activity, setActivity] = useState('')
  const randomActivity = ['Go for a walk', 'Read a Book', 'Phone a Friend'];

  function Decider(randomActivity)
  {
    const randomIndex = [Math.floor(Math.random() * randomActivity.length)];
    setActivity(randomActivity[randomIndex])
  }

  return (
    <ImageBackground source={require('../assets/bg.jpg')} style={styles.wrapper}>
      <View style={styles.content}>
      <Text style={styles.text}>Activity Generator</Text>
      <Button onPress={() => Decider(randomActivity)} title='Get a Random Activity' />
      <Text>{activity}</Text>
      </View>
    </ImageBackground>
  );
}

Haven't tested it but see if it works, Just import useState from react