mirror of
https://github.com/lainbo/component-party.git
synced 2026-04-05 04:59:02 +08:00
react: remove useMemo for simple calculation
It's not idiomatic to use useMemo for such a cheap calculation. https://canimerge.com/should-you-really-use-usememo-in-react-lets-find-out/ https://blog.logrocket.com/rethinking-hooks-memoization/
This commit is contained in:
@@ -2,7 +2,7 @@ import { useState, useMemo } from 'react';
|
||||
|
||||
export default function DoubleCount() {
|
||||
const [count] = useState(10);
|
||||
const doubleCount = useMemo(() => count * 2, [count]);
|
||||
const doubleCount = count * 2;
|
||||
|
||||
return <div>{doubleCount}</div>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user