摘要:
() => { const stringifyData = data => JSON.stringify(data, null, 2) const initialData = stringifyData({ data: null }) const [data, setData] = useState 阅读全文
摘要:
A custom Hook is a JavaScript function whose name starts with ”use” and that may call other Hooks import { useEffect, useCallback } from "react"; // C 阅读全文
摘要:
useMemo returns a memoized value. Pass a “create” function and an array of dependencies. useMemo will only recompute the memoized value when one of th 阅读全文
摘要:
useLayoutEffect has the very same signature as useEffect. useLayoutEffect(effectFunction, arrayDependencies) () => { const [randomNumber, setRandomNum 阅读全文
摘要:
useCallback returns a memoized callback. const memoizedCallback = useCallback(function, arrayDependency) const App = () => { const [age, setAge] = use 阅读全文
摘要:
returns a 'ref' object. const refContainer = useRef(initialValueToBePersisted) Value is persisted in the refContainer.current property. values are acc 阅读全文
摘要:
useReducer may be used as an alternative to useState. const [state, dispatch] = useReducer(reducer, initialState, lazyInitFunction) Ideal for complex 阅读全文
摘要:
useContext saves you the stress of having to rely on a Context consumer. const contextValue = useContext(contextObject) // consuming context via a con 阅读全文
摘要:
useEffect accepts a function which can perform any side effects. useEffect(effectFunction, arrayDependencies) 每次绘制都执行 Without an array dependency, the 阅读全文
摘要:
useState lets you use local state within a function component. The setState function is used to update the state. It accepts a new state value and enq 阅读全文