In the following example, I used history to redirect some link.
const history = useHistory()
useEffect(() => {
history.push(`/my/link`)
}, [])
Then react complains a missing dependency history. I do not understand why history can be a dependency here. It is not a state variable or from props.
If I add history to the dependency array, will it cause an infinite call of useEffect. Because history is changed when history.push(/my/link) happens.
const history = useHistory()
useEffect(() => {
history.push(`/my/link`)
}, [history])
Is my understanding correct here?