参考: React Snippets
Function Component
rafce
import React from 'react'
const aaa = () => {
return (
<div>aaa</div>
)
}
export default aaa
rafc
import React from 'react'
export const aaa = () => {
return (
<div>aaa</div>
)
}
rfce
import React from 'react'
function aaa() {
return (
<div>aaa</div>
)
}
export default aaa
rfc
import React from 'react'
export default function aaa() {
return (
<div>aaa</div>
)
}
useState Hook
ush
const [, set] = useState();
useEffect Hook
ueh
useEffect(() => {
return cleanUp = () => {
}
}, []);
useContext Hook
uch
const = useContext();
useReducer Hook
urdh
const [state, dispatch] = useReducer(reducer, initialArg, init);
useRef Hook
urh
const = useRef();
useMemo Hook
urh
const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]);
useCallback Hook
ucbh
const memoizedCallback = useCallback(
() => {
doSomething(a, b)
},
[a, b],
);
useSelector Hook
uss
const = useSelector(state => state.);
useDispatch Hook
usdf
const = useDispatch();