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

Error in using preact-compat on a minimal CRA app (react 16). Is it even compatible with React 16? #498

Closed wondermang closed 4 years ago

wondermang commented 6 years ago

Hello. After deciding to move to Preact, i tried to see how preact-compat works first. so i tried it on a minimal react16 app created with create-react-app:

1- I created a new React app using create-react-app cli 2- I ejected application to have access to webpack config files 3- I installed preact and preact-compat using npm 4- Then added aliases to webpack.config.prod.js as mentioned here 5- Then i used preact build --no-prerender to build for production 6- When i tried to serve the app from build directory, it did not work :/

I get an error in browser console saying: alt text

It happen in render$1 function in preact-compat.es.js file: alt text

Which is called from ReactDOM.render function from index.js (entry of react app): alt text

Did i miss anything? I tried using preact-compat on several projects of mine and got same error every single time.

developit commented 6 years ago

Hmm - why are you using preact build? If it's a create-react-app application, you should build the same way you would any other create-react-app application. Preact CLI isn't required to use Preact.