Coder Social home page Coder Social logo

Comments (5)

PengBoUESTC avatar PengBoUESTC commented on June 3, 2024

U can use like this to avoid this problem
export default () => <Alert></Alert>

I think react-refresh doesn't register component correctly

project create by npx create-react-app my-app , but HMR in this project is ok ..
__webpack_require__.$Refresh$.register(_c, "Asd");

your project
$RefreshReg$(_c, "Asd");

from vite-plugin-react.

robertmusil avatar robertmusil commented on June 3, 2024

@PengBoUESTC usually I'd export several styled components from one file, I guess that's a pretty standard thing to do too, so using defaults doesn't solve it.

And you're right, it works out of the box in CRA
https://codesandbox.io/s/dazzling-mirzakhani-gpshjc?file=/src/HmrTest.tsx

from vite-plugin-react.

PengBoUESTC avatar PengBoUESTC commented on June 3, 2024

that is a bit strange, =_=, because these two project register the HmrTest in same way, maybe vite project is correct...

from vite-plugin-react.

nodegin avatar nodegin commented on June 3, 2024

I found that you need to name your every component to get HMR work properly, anonymous function doesn't have a name

from vite-plugin-react.

robertmusil avatar robertmusil commented on June 3, 2024

@nodegin But my example doesn't work even if I have "Asd" created as a named function

from vite-plugin-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.