Skip to content
This repository was archived by the owner on Jul 24, 2025. It is now read-only.

feat: support HMR for class components#203

Merged
ArnaudBarre merged 1 commit intomainfrom
class-components
May 20, 2024
Merged

feat: support HMR for class components#203
ArnaudBarre merged 1 commit intomainfrom
class-components

Conversation

@ArnaudBarre
Copy link
Copy Markdown
Member

@ArnaudBarre ArnaudBarre commented May 8, 2024

Fixes #136
Fixes #199
Closes #200

I merged ideas from @n9 in #200 and @marlo22 in fix-react-refresh-plugin

I will port the fix to the Babel plugin once merged to fix oldest issue in the React plugins!

Copy link
Copy Markdown
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to understand the changes, does this mean that react-refresh had always supported HMR for class components? And the window.$RefreshReg$ code is only needed if it contains function components with hooks?

@ArnaudBarre
Copy link
Copy Markdown
Member Author

Yes exactly!
But he support is more limited, the component will restart from scratch everytime.
Because of that the react refresh transformation don't output special code and the current condition was not working for files with only class components.
Because I stopped worked with class components since 2019 I didn't took time to test it 😬

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

3 participants