# Refactoring React code with Glean

- Speaker: [Boris Litvinsky](/wiki/speakers/boris-litvinsky.md)
- Event: [Reversim Summit 2019](/wiki/years/2019.md)
- Video: https://www.youtube.com/watch?v=4hhRDiWVOg0
- Transcript: [/transcripts/2019/31-4hhRDiWVOg0.md](/transcripts/2019/31-4hhRDiWVOg0.md)
- Language: Hebrew · Type: talk · Level: intermediate
- Topics: [Developer Experience](/wiki/topics/developer-experience.md), [Frontend](/wiki/topics/frontend.md), [Productivity](/wiki/topics/productivity.md), [Technical Debt](/wiki/topics/technical-debt.md)

> Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.

## Summary

The speaker discusses the limitations of refactoring tools in the JavaScript ecosystem, specifically highlighting how manual refactoring of React components is tedious and error-prone. The talk introduces a tool called Glean, a Visual Studio Code extension designed to automate common React refactoring tasks like extracting components and converting between class and functional components. Through a live demonstration, the speaker showcases how Glean handles complex code transformations, including TypeScript support and integration with React Hooks. The main takeaway is that developers can build their own productivity tools using existing knowledge to overcome ecosystem gaps.

## Key points

- [0:10](https://www.youtube.com/watch?v=4hhRDiWVOg0&t=10s) The JavaScript community is innovative and fast-moving, but development environments lag behind other languages regarding refactoring capabilities.
- [1:39](https://www.youtube.com/watch?v=4hhRDiWVOg0&t=99s) Manual refactoring tasks in React, such as extracting a few lines into a new component, require tedious boilerplate changes like managing imports and fragments.
- [2:44](https://www.youtube.com/watch?v=4hhRDiWVOg0&t=164s) IDE and editor creators cannot keep up with the rapid pace of frontend framework changes and ecosystem evolution.
- [3:47](https://www.youtube.com/watch?v=4hhRDiWVOg0&t=227s) The speaker introduces Glean, a Visual Studio Code extension built by the community to provide automated React refactoring capabilities.
- [4:47](https://www.youtube.com/watch?v=4hhRDiWVOg0&t=287s) A live demonstration shows how Glean can automatically extract JSX into a new file and handle props and imports.
- [5:56](https://www.youtube.com/watch?v=4hhRDiWVOg0&t=356s) The extension supports converting between class components and functional components, including handling TypeScript annotations.
- [7:01](https://www.youtube.com/watch?v=4hhRDiWVOg0&t=421s) Advanced features include converting class component state and lifecycle methods to React Hooks using experimental flags.

## Takeaways

- Automate repetitive frontend refactoring tasks using specialized editor extensions.
- Leverage community-driven open-source tools to bridge gaps in standard development environments.
- Utilize modern refactoring tools to safely convert legacy class components into functional components with hooks.

## Questions this talk answers

- How can I automate the extraction of JSX code into a separate React component?
- What tool can help me convert React class components to functional components using hooks?
- How do modern editor extensions handle TypeScript types during React refactoring?

## Technologies

React, TypeScript, Visual Studio Code, JavaScript

## Tags

developer tools, react, react hooks, refactoring, typescript, vscode
