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
Custom useEffect with a unified cancellation mechanism to ensure complete cleanup and to prevent the warning that appears on old React version _"Can't perform a React state update on an unmounted component"_. [See demo](https://react-tools.ndria.dev/#/hooks/lifecycle/useEffectAbortable)
Custom useEffect that reexecutes EffectCallback only when comparator function, received as third parameter, returns true. [See demo](https://react-tools.ndria.dev/#/hooks/lifecycle/useEffectCompare)
@@ -364,6 +373,13 @@ Hoos to know when a component is mounted or not. [See demo](https://react-tools.
364
373
useIsMounted(): ()=>boolean
365
374
```
366
375
376
+
### useLayoutEffectAbortable
377
+
378
+
Custom useLayoutEffect with a unified cancellation mechanism to ensure complete cleanup and to prevent the warning that appears on old React version _"Can't perform a React state update on an unmounted component"_. [See demo](https://react-tools.ndria.dev/#/hooks/lifecycle/useEffectAbortable)
Custom useLayoutEffect that reexecutes EffectCallback only when comparator function, received as third parameter, returns true. [See demo](https://react-tools.ndria.dev/#/hooks/lifecycle/useLayoutEffectCompare)
Custom useEffect with a unified cancellation mechanism to ensure complete cleanup and to prevent the warning that appears on old React version _"Can't perform a React state update on an unmounted component"_. [See demo](https://react-tools.ndria.dev/#/hooks/lifecycle/useEffectAbortable)
> - a _state useState variable_ boolean uaws by a Show component to render the _Demo component_.
50
+
> - a _data useState variable_ with value 0.
51
+
> - a button that toggle _state between __false__ and __true__ value.
52
+
> - a _Demo component_ that receives the update function for _data variable_. It has a _useEffectAbortable_ that hat simulates an asynchronous call during which a loading message is shown and at the end of which increment by one _date varibale_.
53
+
>
54
+
> If you click the _mount button_ the _Demo component_ is rendering. The simulated call starts and at the end updates the _date variable_ but if the _unmount button_ is clicked before call ending, it will be canceled with the _useEffectAbortable_ and _date variable_ will not be updated.
Custom useLayoutEffect with a unified cancellation mechanism to ensure complete cleanup and to prevent the warning that appears on old React version _"Can't perform a React state update on an unmounted component"_. [See demo](https://react-tools.ndria.dev/#/hooks/lifecycle/useEffectAbortable)
3
+
4
+
## Usage
5
+
6
+
The implementation is like that _useEffectAbortable_.
7
+
8
+
Please visit [useEffectAbortable](#/hooks/lifecycle/useEffectAbortable) example to see how it works.
- a _state useState variable_ boolean uaws by a Show component to render the _Demo component_.
8
+
- a _data useState variable_ with value 0.
9
+
- a button that toggle _state between __false__ and __true__ value.
10
+
- a _Demo component_ that receives the update function for _data variable_. It has a _useEffectAbortable_ that hat simulates an asynchronous call during which a loading message is shown and at the end of which increment by one _date varibale_.
11
+
12
+
If you click the _mount button_ the _Demo component_ is rendering. The simulated call starts and at the end updates the _date variable_ but if the _unmount button_ is clicked before call ending, it will be canceled with the _useEffectAbortable_ and _date variable_ will not be updated.
- A _useStateGetReset_ that receives an object, with three properties _id_, _name_, _eta_, and returns a tuple with _stateG_, _setterG_, _getter_ and _resetter_.
0 commit comments