My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Is there any alternative to React Context?

Nicos Tsourektsidis's photo
Nicos Tsourektsidis
·Apr 26, 2016

I'm trying to create a UI library in which every little component would be responsible to style itself according to its props. I have props like size, color and some other modifiers like rounded, centered and so on.

The cool part is that you can display a button wherever you want with the style that you want. The not cool part is that you have to specify these props every single time, for example every time you render an custom input component you have to pass the style modifier rounded, because in another part of application we want the same component without rounded corners.

React Context helps us a lot to specify theme parameters in the root components. But as they say it's an experimental feature. I don't think we should build upon it.

Have you ever experienced the same issue before? Is there any library you used that can help? Maybe a pattern or something?