Hey, I'm just trying to understand what was your motivation to create this, that React-Styles doesn't offer? Why would I use this over React-Style?
Hi @paulwehner, great question.
react-style and Radium are both rapidly changing libraries under constant development. This is true of pretty much all of the libraries dealing with React component styling.
For some historical context: When we initially released Radium, react-style didn't use inline styles and worked quite a bit differently than it does now. In the time since, react-style has added inline style support and both libraries have converged on fairly similar APIs (both influenced by React Native).
Some of the major differences between the libraries now are:
:hover, and will introduce keyframe animation support soon. react-style doesn't plan on supporting either.ReactElement.createElement while Radium wraps React.createClass for the same purpose.You might also be interested in https://github.com/petehunt/jsxstyle and https://github.com/VirtualCSS/planning, two other libraries (VirtualCSS is a theoretical WIP at the moment but is progressing quickly) for React component styling that are making good progress in this space.
Thanks for the detailed follow-up!
Are you guys not supporting extracting styles into external CSS because performance is equivalent without this feature? Or is it because you expect other people to figure out how to extract the styles Radium creates?
Why does it matter that Radium wraps React.createClass vs monkey patching ReactElement.createElement? I'm not familiar enough with React to know why this is important.
Right. We haven't seen performance issues with inline styles vs extracted CSS, and we find inline styles easier to reason about in general. I wouldn't recommend trying to extract Radium styles. If you're interested in extracting things into CSS (or even into a <style> tag) I would recommend one of the other libraries I mentioned previously.
Re: monkey patching, without going into it too much, it's effectively a stylistic choice. Radium is explicit about the wrapping. When you require react-style into your app, it monkey patches React behind the scenes, which you may or may not be comfortable with.
A couple other notes on monkey-patching -- I generally try to avoid monkey-patching, because:
ReactElement.createElement just from a mere require. Before the require ReactElement.createElement behaves one way, after it behaves differently. This hidden behavior change can sometimes be the cause of bugs and makes things just a little harder to reason about.ReactElement.createElement.ReactElement.createElement changes in the future, the patch immediately stops working.All that said, the patch looks pretty small and safe, so perhaps not the biggest deal here.
Ultimately, though, my rule of thumb is that monkey patching in your _own app_ is fine as there's nothing else downstream, but should be avoided wherever possible in open _libraries_ that will be consumed widely by the community...
Thanks for the detailed explanation.
Let's please get this into the readme, I'd like to make an entire section on strengths-weaknesses of Radium vs other options.
Agreed.
Think we can close this one.
Most helpful comment
Hi @paulwehner, great question.
react-style and Radium are both rapidly changing libraries under constant development. This is true of pretty much all of the libraries dealing with React component styling.
For some historical context: When we initially released Radium, react-style didn't use inline styles and worked quite a bit differently than it does now. In the time since, react-style has added inline style support and both libraries have converged on fairly similar APIs (both influenced by React Native).
Some of the major differences between the libraries now are:
:hover, and will introduce keyframe animation support soon. react-style doesn't plan on supporting either.ReactElement.createElementwhile Radium wrapsReact.createClassfor the same purpose.You might also be interested in https://github.com/petehunt/jsxstyle and https://github.com/VirtualCSS/planning, two other libraries (VirtualCSS is a theoretical WIP at the moment but is progressing quickly) for React component styling that are making good progress in this space.