With React Native Material, I am trying to implement a loading feature when a button is clicked. The goal is to show the "loading" message only when the button is active, and hide it otherwise. Additionally, I would like for the loading message to disappear either after 5 seconds or when navigating to a different page.
My attempt at using an if statement within the onPress function to display the loading message resulted in an error.
https://i.stack.imgur.com/j8Nyo.png
Code:
<Button
title="Submit Answers"
onPress={CalculateTotal}
loading
/>