Related issue: #508
Currently,the config callbacks captured by the eventsRef is the callbacks created in the initial render of the component.
If the config callbacks is pure, everything is fine.
but if the config callbacks rely on some variables of the components , it would cause some bugs related to the stale closure.
solution
I think if the useSWR hook read the config callbacks via useRef would be great, but this may bring some bugs if some APP rely on the current behavior of the config callbacks.
const eventsRef = useRef({
emit: (event, ...params) => {
if (unmountedRef.current) return
configRef.current[event](...params)
}
})
what do you think?