You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const myHook = hook => {
// do stuff
if (hook.type)...
// optionally change stuff in hook
hook.result = {...};
return hook; // <-- do I need to do this? Even if I modified data inside 'hook'?
}
My question: if we don't create a new hook object but simply mutate the existing one, is return hook necessary? I don't think it is but I haven't seen it explicitly documented anywhere.
I do realize that if you
...
// you can also change the entire hook object
const newHook = Object.assign({}, hook);
return newHook; // you MUST do this
then you have to explicitly return the context.
Is there a preferred "you should always return the hook context from any hook that modifies hook data?" style or convention to follow?
The text was updated successfully, but these errors were encountered:
A hook generally follows the form
My question: if we don't create a new hook object but simply mutate the existing one, is
return hook
necessary? I don't think it is but I haven't seen it explicitly documented anywhere.I do realize that if you
then you have to explicitly return the context.
Is there a preferred "you should always return the hook context from any hook that modifies hook data?" style or convention to follow?
The text was updated successfully, but these errors were encountered: