I have got 6 different buttons on one page that each need to open a modal window. Now I don't want to write out 6 different modals. So when the user presses the first button it will pull up a modal with the reported info on the "shopping info", whereas on the second button it would bring up the info on "graphical info".
const [modalVisible, setModalVisible] = useState(false);
<TouchableOpacity style={styles.expensesList} onPress={() => {setModalVisible(true)}}>
<FontAwesome5 name="shopping-cart" size={40} color="black" style={styles.iconStyle} />
</TouchableOpacity>
<TouchableOpacity style={styles.expensesList} onPress={}> {/* Different modal? */}
<Foundation name="graph-bar" size={40} color="black" />
</TouchableOpacity>
<Modal
animationType="slide"
transparent={true}
visible={modalVisible}
style={{ margin: 0 }}
onRequestClose={() => {}}>
// Different info based on which button was pressed
</Modal>
These are for reporting purposes so each one will have the same styling and close button. But I want to be able to only have one modal that opens different ones dependent on which button was pressed. Is this doable?
If I am not clear enough please let me know. I am new to React Native.
EDIT - I am NOT trying to open multiple modals at once. Only one will be open at a time. But I want to be able to change the info in the ONE modal, dependent on which button was clicked.