Initial project import
This commit is contained in:
17
node_modules/@react-three/drei/helpers/useEffectfulState.js
generated
vendored
Normal file
17
node_modules/@react-three/drei/helpers/useEffectfulState.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import * as React from 'react';
|
||||
|
||||
function call(ref, value) {
|
||||
if (typeof ref === 'function') ref(value);else if (ref != null) ref.current = value;
|
||||
}
|
||||
function useEffectfulState(fn, deps = [], cb) {
|
||||
const [state, set] = React.useState();
|
||||
React.useLayoutEffect(() => {
|
||||
const value = fn();
|
||||
set(value);
|
||||
call(cb, value);
|
||||
return () => call(cb, null);
|
||||
}, deps);
|
||||
return state;
|
||||
}
|
||||
|
||||
export { useEffectfulState };
|
||||
Reference in New Issue
Block a user