Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support HMR for class components #203

Merged
merged 1 commit into from May 20, 2024
Merged

Conversation

ArnaudBarre
Copy link
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
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
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 😬

@ArnaudBarre ArnaudBarre merged commit 53878df into main May 20, 2024
1 check passed
@ArnaudBarre ArnaudBarre deleted the class-components branch May 20, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants