preactjs / preact-compat

ATTENTION: The React compatibility layer for Preact has moved to the main preact repo.
http://npm.im/preact-compat
MIT License
949 stars 148 forks source link

Issue with react-hot-loader #457

Open stephanpelikan opened 6 years ago

stephanpelikan commented 6 years ago

I'm using react-hot-loader for preserving component's state on HMR. This seems to work. But on the very first change after initial page load I get this error:

deepforceupdate-error

The change itself is applied and also state is preserved. Every further change runs without this error and is applied as well.

I tried using preact-deep-force-update

                resolve : {
                        alias: {
                                'react': 'preact-compat',
                                'react-dom': 'preact-compat',
                                'create-react-class': 'preact-compat/lib/create-react-class',
                                'preact-compat': 'preact-compat/dist/preact-compat',
                                'react-deep-force-update': 'preact-deep-force-update'
                        },
                        extensions : [ '.tsx', '.ts', '.js' ]
                },

but then the feature of preserving state is not and only pure HMR is working.

As you can see on the screenshot am even starting my project and I'm using preact for the first time. So I'm not sure the react-hot-loader is fully operational when I get this error. I hope you can tell me whether subsequent code of the function causing the error matters to preact HMR or you even can provide a workaround/solution for this issue.

Thx, Stephan

By the way: I'm using Typescript and not Babel. But I don't think this matters at all.

PS: My dependencies are

    "dependencies": {
            "preact": "^8.2.7",
            "preact-compat": "^3.17.0"
    },
    "devDependencies": {
            "react-hot-loader": "^3.1.3",
            "preact-deep-force-update": "0.1.0",
            ....
developit commented 6 years ago

I believe you need to use an older version of React Hot Loader, one that doesn't rely on Fiber internals.

stephanpelikan commented 6 years ago

I used every version down to 3.0.0: Always the same result. The next version before is 1.3.0 but this version does not work at all.

They are heavily working on 4.0.0. Will this be compatible to preact? If not, do you have any plans regarding hmr and preact?

developit commented 6 years ago

Not sure - as far as I'm aware, the RHL folks don't pay much attention to Preact.