I'm learning useEffect and useCallBack hooks. What I'm trying to do is add a function in the useCallBack, and make sure that the screen will not call this function until I click on a button. Here is my sample code below. Currently, it calls the function inside useEffect before I click on the button. My goal is to click on the button then trigger the useEffect function with useCallBack function. Still new to this, thanks for helping out.
import React, {useState, useEffect, useCallback} from 'react';
import {Button, StyleSheet, View} from 'react-native';
const submitHandler = useCallback(() => {
console.log('the inputs tracking');
}, []);
useEffect(() => {
console.log('Should not be work until submitHandler button is clicked');
}, [submitHandler]);
return (
<View>
<Button title="Click me" onPress={submitHandler}></Button>
</View>
)