摘要: () => { const stringifyData = data => JSON.stringify(data, null, 2) const initialData = stringifyData({ data: null }) const [data, setData] = useState 阅读全文
posted @ 2020-10-26 13:18 fndefbwefsowpvqfx 阅读(70) 评论(0) 推荐(0) 编辑
摘要: A custom Hook is a JavaScript function whose name starts with ”use” and that may call other Hooks import { useEffect, useCallback } from "react"; // C 阅读全文
posted @ 2020-10-26 13:16 fndefbwefsowpvqfx 阅读(79) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2020-10-26 13:15 fndefbwefsowpvqfx 阅读(64) 评论(0) 推荐(0) 编辑
摘要: useLayoutEffect has the very same signature as useEffect. useLayoutEffect(effectFunction, arrayDependencies) () => { const [randomNumber, setRandomNum 阅读全文
posted @ 2020-10-26 13:13 fndefbwefsowpvqfx 阅读(51) 评论(0) 推荐(0) 编辑
摘要: useCallback returns a memoized callback. const memoizedCallback = useCallback(function, arrayDependency) const App = () => { const [age, setAge] = use 阅读全文
posted @ 2020-10-26 13:12 fndefbwefsowpvqfx 阅读(60) 评论(0) 推荐(0) 编辑
摘要: returns a 'ref' object. const refContainer = useRef(initialValueToBePersisted) Value is persisted in the refContainer.current property. values are acc 阅读全文
posted @ 2020-10-26 13:10 fndefbwefsowpvqfx 阅读(51) 评论(0) 推荐(0) 编辑
摘要: useReducer may be used as an alternative to useState. const [state, dispatch] = useReducer(reducer, initialState, lazyInitFunction) Ideal for complex 阅读全文
posted @ 2020-10-26 13:08 fndefbwefsowpvqfx 阅读(48) 评论(0) 推荐(0) 编辑
摘要: useContext saves you the stress of having to rely on a Context consumer. const contextValue = useContext(contextObject) // consuming context via a con 阅读全文
posted @ 2020-10-26 13:07 fndefbwefsowpvqfx 阅读(46) 评论(0) 推荐(0) 编辑
摘要: useEffect accepts a function which can perform any side effects. useEffect(effectFunction, arrayDependencies) 每次绘制都执行 Without an array dependency, the 阅读全文
posted @ 2020-10-26 13:05 fndefbwefsowpvqfx 阅读(75) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2020-10-26 13:04 fndefbwefsowpvqfx 阅读(87) 评论(0) 推荐(0) 编辑