How to use the useEffect function from react
Find comprehensive JavaScript react.useEffect code examples handpicked from public code repositorys.
94 95 96 97 98 99 100 101 102 103
ref.setDestinations = setDestinations; } }, }); React.useEffect(() => { if (destinationsProp != null) { setDestinations(destinationsProp); } }, [setDestinations, destinationsProp]);
108
594
27
GitHub: szhsin/react-menu
474 475 476 477 478 479 480 481 482 483
timeoutId.current = 0; } !keepHover && unsetHover(); }; useItemEffect(isDisabled, itemRef, updateItems); react.useEffect(function () { return function () { return clearTimeout(timeoutId.current); }; }, []);
48
881
6
+ 9 other calls in file
GitHub: Malvid/Malvid
29 30 31 32 33 34 35 36 37 38
return `${ props.currentComponent.name } | ${ props.opts.title }` })() useEffect(() => { document.documentElement.style.setProperty('--size-vertical', `${ props.size.vertical }px`) }, [ props.size.vertical ]) useEffect(() => { document.documentElement.style.setProperty('--size-horizontal', `${ props.size.horizontal }px`) }, [ props.size.horizontal ]) useEffect(() => { document.title = title }, [ title ]) // Something went wrong
23
359
13
+ 5 other calls in file
GitHub: szhsin/react-accordion
179 180 181 182 183 184 185 186 187 188 189
Accordion.displayName = 'Accordion'; let current = 0; const useIdShim = () => { const [id, setId] = react.useState(); react.useEffect(() => setId(++current), []); return id && `${ACCORDION_PREFIX}-${id}`; }; const _useId = react.useId || useIdShim;
4
84
0
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302
var _useState = React.useState({}), _useState2 = _slicedToArray(_useState, 1), _key = _useState2[0]; React.useEffect(function () { previousData.set(_key, {}); initialRender.set(_key, true); return function () { previousData.delete(_key);
6
9
3
+ 11 other calls in file
GitHub: tahl04/bonescatch
36 37 38 39 40 41 42 43 44
trans = await axios.post("http://localhost:3000/api", obj); } setData(trans); } useEffect(() => { dataFun("get"); dataPost("get"); }, []);
0
1
1
+ 8 other calls in file
91 92 93 94 95 96 97 98 99 100 101
const useObservable = (paths, timeout = 100) => { if (!paths) return; paths = split(/\s*,\s*/, paths); const [v, s] = useState(0); const rerender = timeout ? throttle(timeout, () => s(v + 1)) : () => s(v + 1); useEffect(() => juxt(paths.map((p) => State.subscribe(p, rerender)))); return State; }; module.exports = {
0
0
1
+ 2 other calls in file
GitHub: daneg69/quizmeapp
27 28 29 30 31 32 33 34 35 36
catch (e) { logger(e); return defaultValue; } }), storedValue = _a[0], setValue = _a[1]; react_1.useEffect(function () { if (typeof window === "undefined") return; var updateLocalStorage = function () { if (storedValue !== undefined) {
0
0
0
137 138 139 140 141 142 143 144 145 146
* So if we detect a situtation where optimised appear animations * are running, we use useLayoutEffect to trigger animations. */ const useAnimateChangesEffect = window.HandoffAppearAnimations ? useIsomorphicLayoutEffect : React.useEffect; useAnimateChangesEffect(() => { if (visualElement && visualElement.animationState) { visualElement.animationState.animateChanges(); }
0
0
1
+ 10 other calls in file
GitHub: teu-ai/ant-design
38 39 40 41 42 43 44 45 46 47
// ========================== Effect ========================== var _React$useState = React.useState([]), _React$useState2 = (0, _slicedToArray2['default'])(_React$useState, 2), actionQueue = _React$useState2[0], setActionQueue = _React$useState2[1]; React.useEffect( function () { if (actionQueue.length) { var cloneQueue = (0, _toConsumableArray2['default'])(actionQueue); cloneQueue.forEach(function (action) {
0
0
2
react.default is the most popular function in react (505 examples)