Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Allow props to be a plain string, specifying className #3408
A tiny, low-impact (basically non-breaking) change that I find makes a big difference to succinctness when rendering without JSX. I've added a minimal test, checked lint, and submitted the CLA.
Render declaration trees tend to frequently include instances of
Also with ES destructuring assignment, I can say:
This succinctly imports frequently used elements into the scope, and combined with this pull-request, allows me to write render functions like this:
This makes it somewhat more succinct than JSX! :)
The prior code was written to assume that props is an object, so this change simply checks for a string and converts it to an object with a property
Regarding static typing, no change is required to the
Furthermore, designers of components could optionally support a
className doesn't have any significance in other environments, like React Native. You're free to create a wrapper in your own code for this if you prefer but we won't support it as part of the core. Thanks for sending in the idea though – always good to have people thinking about how we can make the API better.
No problem, I wrote it as an external wrapper to begin with.
To emphasise again, under this change