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

Not work with AntD #546

Closed michaelpeterlee closed 3 years ago

michaelpeterlee commented 3 years ago

We receive many webpack errors that emanate from AntD, many errors reference useEffect.

npm i -S preact preact-compat

Webpack:
module.exports = {
      "resolve": {
        "alias": {
          "react": "preact-compat",
          "react-dom": "preact-compat"
        }
      },
}
"webpack": "^5.24.2",
"webpack-cli": "^4.5.0",
"ant-design-pro": "^2.3.2",
"antd": "^4.10.3",
marvinhagemeister commented 3 years ago

Preact 8.x -> preact-compat Preact 10.x -> preact/compat, note the / character.

Excerpt from our docs on how to set up webpack aliasing:

{ 
  "resolve": { 
    "alias": { 
      "react": "preact/compat",
      "react-dom/test-utils": "preact/test-utils",
      "react-dom": "preact/compat",
    },
  }
}

Replacing preact-compat with preact/compat in your config fixes your issue.