title: Is there a way i can wait for a state to be set before rendering?
body: <p>I'm building an ETH wallet for iOS.
  This is just a prototype of a screen, but I'm facing an error.
  Everything works just fine, except the part where i have to map through the transactions.
  Well, the thing is it renders the app before it fetches the transactions, so it would always show an error when mapping and that it's not a function.</p>
  <p>However, if i preload the transactions, change code and reload, it would map ( only for one time ), reload again and the errors are back.</p>
  <p>Is there anything i can do about this?</p>
  <pre><code>const Wallet = ({ navigation }) =&gt; {
      const Tab = createMaterialTopTabNavigator();
      const [ wallet, setWallet ] = useState(&quot;⌛&quot;);
      const [ address, setAddress ] = useState(&quot;⌛&quot;);
      const [ balance, setBalance ] = useState(&quot;⌛&quot;);
      const [ mnemonic, setMnemonic ] = useState(&quot;⌛&quot;);
      const [ transactions, setTransactions ] = useState();
      console.log(transactions)
      useEffect(async () =&gt; {
          const retrieve_connect = async () =&gt; {
              const result = await SecureStore.getItemAsync(&quot;pKey&quot;);
              if (result) {
                  const decoded = await JWT.decode(result, &quot;1239SEH9S8FH9S8EFSUEFBSIUFENEIU&quot;);
                  if (!decoded ) {
                      navigation.push('SignUp')
                  }
                  console.log(decoded);
                  setAddress(decoded.address);
                  setWallet(decoded.privateKey);
                  setMnemonic(decoded.mnemonicPhrase);
              } else {
                  navigation.push('SignUp')
              }
              const connection = new ethers.getDefaultProvider('kovan');
              // ethers.providers.JsonRpcProvider('https://eth-mainnet.alchemyapi.io/v2/aw_ATN5yoZ578XsQUVEhaevmchG9e_iT');
              const decode = await JWT.decode(result,&quot;1239SEH9S8FH9S8EFSUEFBSIUFENEIU&quot;)
              if (!decode) {
                  navigation.push('SignUp');
              }
              const wallet = new ethers.Wallet(decode.privateKey);   
              const signer = wallet.connect(connection);
              const addy = await signer.getAddress();
              const balance = await signer.getBalance();
              const response = await fetch(`https://api-kovan.etherscan.io/api?module=account&amp;action=txlist&amp;address=${addy}&amp;startblock=0&amp;endblock=99999999&amp;page=1&amp;offset=10&amp;sort=asc&amp;apikey=2KQ9YKPQ1VG4E5FE4PUG7E5CHJWIVK2D43`)
              const res = await response.json();
              const transactions = await res.result;
              setTransactions(res.result)
              console.log(transactions);
              setBalance(ethers.utils.formatEther(balance._hex));
              setAddress(addy);
          }
          const save = async () =&gt; {
              await SecureStore.setItemAsync(&quot;key&quot;, &quot;test 123&quot;)
          }
          save();
          console.log(address);
          retrieve_connect();
      }, [])
      const copyToClipboard = () =&gt; {
          Clipboard.setString(address);
          Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
        };
        // only for beta testing.
        const copyPrivateKey = () =&gt; {
          Clipboard.setString(wallet);
        };
        // Share Button
        const onShare = async () =&gt; {
          Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
          try {
            const result = await Share.share({message:address});
            if (result.action === Share.sharedAction) {
              if (result.activityType) {
                // shared with activity type of result.activityType
              } else {
                // shared
              }
            } else if (result.action === Share.dismissedAction) {
              // dismissed
            }
          } catch (error) {
            alert(error.message);
          }
        };
      return (
          &lt;View style={styles.container}&gt;
              {/* &lt;Text&gt;Below is your Address.&lt;/Text&gt; */}
              &lt;View style={styles.secondContainer}&gt;
                  &lt;Button style={styles.ButtonText} onPress={copyToClipboard} title={`${address.substring(0, 15)}..`} /&gt;
                  &lt;/View&gt; 
              {/* &lt;Text&gt;Below is your PrivateKey&lt;/Text&gt;
              &lt;TouchableOpacity onPress={copyPrivateKey}&gt;
              &lt;Text&gt;{JSON.stringify(wallet)}&lt;/Text&gt;
              &lt;/TouchableOpacity&gt;
              &lt;TouchableOpacity&gt;
              &lt;Text&gt;{JSON.stringify(mnemonic)}&lt;/Text&gt;
              &lt;/TouchableOpacity&gt; */}
              &lt;View style={styles.thirdContainer}&gt;
              &lt;Text&gt;Balance:&lt;/Text&gt;
              &lt;TouchableOpacity&gt;
              &lt;Text&gt;{balance} ETH &lt;/Text&gt;
              &lt;/TouchableOpacity&gt;
              &lt;Link to=&quot;/LogOut&quot;&gt;Delete Token&lt;/Link&gt;
              &lt;Link to=&quot;/Send&quot;&gt;Send&lt;/Link&gt;
              {/* { transactions.map(transaction =&gt; &lt;Text key={transaction}&gt;{transaction.hash}&lt;/Text&gt;)} */}
              &lt;/View&gt;
              &lt;View style={styles.fourthContainer}&gt;
              &lt;TouchableOpacity  onPress={onShare}&gt;
                  &lt;LinearGradient colors={['#ee0979','#ff6a00']} start={[0.0, 0.0]} end={[1.0, 1.0]} style={styles.button}&gt;
                  &lt;Text style={styles.TextCopy}&gt;Share Address &lt;/Text&gt;
                  &lt;/LinearGradient&gt;
                  &lt;/TouchableOpacity&gt;
                  &lt;/View&gt;
          &lt;/View&gt;
      )
  }
  
  
  export default Wallet
  
  </code></pre>