facebook / react

The library for web and native user interfaces.

Home Page:https://react.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

toString on classname?

bradennapier opened this issue · comments

Did react used to call .toString() on non string objects it would receive? A few packages are not working anymore and as far as I can tell this is likely the reason. Specifically anything using bem-cn or similar.

Might be something to add to docs as a breaking change.

Can't figure out why else a few components are suddenly throwing errors and dont have any styles on them.

Please provide a plunker.

commented

Please see #10756.

The change was intentional and this is the only library I can see affected so far. The way it works is highly unusual and I believe the benefits of the change (bugs are easier to find) outweigh the downside (a library with an unconventional API stops working).

To be clear we only stopped calling toString on functions. Usually it's their source code, so it's very uncommon to overwrite it to mean something else.

Happy to take PRs mentioning it more prominently in the changelog.

Thanks again @gaearon . I agree that it shouldn't accept functions , just wanted to make sure I wasn't crazy :-P