developit / nextjs-preact-demo

Next.js 9.3 + Preact = 21kB
https://nextjs-preact.now.sh
384 stars 25 forks source link

Source and self shows [object object] #7

Closed wiesson closed 4 years ago

wiesson commented 4 years ago

I don't know if it's a bug, but I wanted to mention it, maybe someone can enlighten me. When running the development version, I see a lot of [object object]s in the dom tree.

Screenshot 2020-04-03 at 22 26 37

// edit: after a quick google search I found that issue https://github.com/preactjs/preact/issues/1058

Okay create-react-app uses the babel plugins: transform-react-jsx-source and transform-react-jsx-self by default in none-production builds. Preact doesn't support those "special" attributes and just adds them as a stringified version to the dom.

I guess it's fine then :)

developit commented 4 years ago

Hiya - this was actually just an oversight and should be fixed on master.

The following two changes are what you'll want to copy into your project:

1. automatically inject preact/debug

This makes preact-devtools work and fixes the issue in your screenshot.

https://github.com/developit/nextjs-preact-demo/commit/c85f8a38d6bcd57367bf8ac7430debe4f3061cb6#diff-5d0c276360a637d1b787a57760665fbeR27-R35

2. Add webpack aliases

This fixes an issue where importing an npm dependency that uses React could end up bringing in a copy of the react package.

https://github.com/developit/nextjs-preact-demo/commit/f31d1dd6bbcf0d1392913274101a2af487e0b8c2#diff-5d0c276360a637d1b787a57760665fbeR26-R29


Closing since I'm fairly certain the above should have things working for you, but please re-open if that's not the case!

yassinebridi commented 4 years ago

@developit, I think this is still showing __source="[object Object]" in the latest master changes.

mike-lischke commented 2 years ago

It is indeed still showing source and self, still today, more than a year later :-(