xsburg / vscode-javascript-booster

Sprinkle extra refactorings, code actions and commands over your JavaScript! 🍩 TypeScript and Flow are first class citizens as well!
https://marketplace.visualstudio.com/items?itemName=sburg.vscode-javascript-booster
159 stars 13 forks source link

Suggestion: React: Wrap value into `useMemo()` hook #34

Open OliverJAsh opened 4 years ago

OliverJAsh commented 4 years ago

The useCallback quick fix is great! Perhaps we could provide a similar fix for useMemo? E.g. to convert

const value = expensiveFn({ someProp })

to

const value = useMemo(() => expensiveFn({ someProp }), [someProp])

or drop the dependency since the React lint rule will automatically fix that

const value = useMemo(() => expensiveFn({ someProp }), [])