4 ms·
I think CSS custom properties in React can be thought of as the inline style equivalent of React context. I think similar caveats (e.g. naming conflicts, confu
by pluma 9y ago
I think CSS custom properties in React can be thought of as the inline style equivalent of React context.
I think similar caveats (e.g. naming conflicts, confusing if overused, hard to debug, etc) apply, actually. Plus, of course, that they don't work in IE 11.
- davnicwil 9y agoAgreed, that is a very good analogy. I was thinking whilst writing that, one of the exceptions where existence of a parent component can/should be assumed is using the 'provider' pattern with React context. And actually, thinking about it for a bit, I see now that css variables could be used to avoid the inconvenience of piping props through to deep children for styling, in a similar way. Still though, like React context, if it's used at all I think it's a special case pattern to use in specific, encapsulated situations where you really need that benefit.