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
The `useFacetCallback` hook is similar to React’s `useCallback` in that it allows you to create a memoized callback that will only be updated if some of the explicit dependencies change. On top of that, `useFacetCallback` allows you to pass in a Facet and get the current value of that facet in the callback body.
56
+
The `useFacetCallback` hook is similar to React’s `useCallback` in that it allows you to create a memoized callback that will only be updated if some of the explicit dependencies change. On top of that, `useFacetCallback` allows you to pass one or more Facets and get the current values of those facets in the callback body.
57
57
58
58
Say for example that you have a small form, and want to create a handler for the Submit action. You need to have access to the current value of a facet that stores the `value` of an input field in order to send that value back to the parent component when the `Submit` button of the form. `useFacetCallback` allows you to create such handler, which will always have access to the current value of the facet.
The `useFacetEffect` hook gives you a way of performing some imperative action (effect) whenever the underlying facet is updated. It is very similar in structure and goal to React’s own `useEffect`.
91
+
The `useFacetEffect` hook gives you a way of performing some imperative action (effect) whenever the underlying facets are updated. It is very similar in structure and goal to React’s own `useEffect`.
92
92
93
-
Like `useEffect`, `useFacetEffect` takes an effect function to be called when the updates happen, a dependency list, and finally a facet.
93
+
Like `useEffect`, `useFacetEffect` takes an effect function to be called when the updates happen, a dependency list, and finally one or more facets.
return <span>{shouldLog?'Logger is active':'Logger is disabled'}</span>
110
110
}
111
111
```
112
112
113
-
It also supports a cleanup function that can be returned by the effect function. This cleanup is called whenever any of the dependencies or the facet has changed or when the component is unmounted. In short, it behaves exactly like React’s `useEffect`.
113
+
It also supports a cleanup function that can be returned by the effect function. This cleanup is called whenever any of the dependencies or the facets have changed or when the component is unmounted. In short, it behaves exactly like React’s `useEffect`.
0 commit comments