wix-incubator / vscode-glean

The extension provides refactoring tools for your React codebase
MIT License
1.46k stars 56 forks source link

Conversion : Convert setState calls to set<Field> hook? #74

Closed gomesalexandre closed 5 years ago

gomesalexandre commented 5 years ago

Everything is in the title :)

Instead of deleting the setState calls, we could easily move that to hooks i.e iterate through the setState calls and write their hooks equivalent at the top of the function.

I can have a look ASAP and publish a PoC PR if that's of any interest !

borislit commented 5 years ago

Hey @gomesalexandre. Thanks for the feedback! Luckly, it's already supported, under experimental hook. Add the following your settings.json to "glean.experiments": ["hooksForFunctionalComponents"]. You should get full hooks support, including useEffect, useCallback, in addition to what You've suggested. Tell me what you think!