tw-in-js / use-twind-with

Twind integration packages for frameworks & libraries with examples
MIT License
68 stars 17 forks source link

@twind/preact: tw and css options cannot be enabled without breakage #9

Closed rschristian closed 3 years ago

rschristian commented 3 years ago

Reproduction

The CodeSandbox linked in the ReadMe reproduces the error. You'll be met by cannot use 'in' operator to search for "tw" in "This is Twind!"

Explanation

Errors are thrown when searching for the tw and css props on an element with text content, assuming those options are enabled. The text content will have props of whatever the content is, i.e., "This is Twind!". Can't use the in operator to search on a string.

Solution?

I'm not sure why that method is used to begin with ("tw" in props), but solution could be as simple as switching that to props.tw or just checking to ensure props is an object first. I don't have the background knowledge here, so you'll likely know better.

danielweck commented 3 years ago

missing sanity check for vnode.type: https://github.com/tw-in-js/use-twind-with/blob/9d2934eddc401ea1beef775d0b1ef80d303f2ea3/packages/preact/index.ts#L51

sastan commented 3 years ago

fixed in v1.0.5

rschristian commented 3 years ago

Thanks!