title: How to display a random text from array on a button press in React Native?
body: <p>I have an array with some phrases that looks like this:</p>
  <pre><code>words = [
  { text: '...', key: 1},
  { text: '...', key: 2},
  { text: '...', key: 3},
  { text: '...', key: 4} ... ]
  </code></pre>
  <p>I want to display a random text from this array when I click a button. This is the code that I have so far:</p>
  <pre><code>import { StatusBar } from 'expo-status-bar';
  import React, { useState } from 'react';
  import { StyleSheet, Text, View, Button } from 'react-native';
  
  export default function App() {
  
  var textValue = 'Change me'
  
  words = [...]
  
  const len = words.length;
  const changeTextValue = () =&gt; {
  textValue = words[Math.floor(Math.random() * len)].text
  }
  
  return (
  &lt;View style={styles.container}&gt;
    &lt;Text&gt;{textValue}&lt;/Text&gt;
    &lt;Button onPress={changeTextValue} title='Press me'/&gt;
    &lt;StatusBar style=&quot;auto&quot; /&gt;
  &lt;/View&gt;
  )
  }
  
  const styles = StyleSheet.create({
  container: {
  flex: 1,
  backgroundColor: 'lightblue',
  alignItems: 'center',
  justifyContent: 'center',
  },
  });
  </code></pre>
  <p>But it doesn't work. Could you please help me with this? Thanks in advance.</p>