0

I am wondering, is it possible to create a global prop in react -- i.e., a prop that works with any component (just like I can use className with any component)?

For example, a flex property that I could call on any component that would have set behavior -- like this:

<Header flex>...</Header>

In this case, it would set display: flex;. This is just a theoretical example. My question is whether or not this is possible -- and, if so, how to do it?

Any ideas?

Moshe
  • 6,011
  • 16
  • 60
  • 112
  • Take a look here: https://stackoverflow.com/questions/53510949/how-to-create-a-global-variable-that-can-be-accessed-in-different-component-in-r – mindmaster Sep 05 '19 at 09:23
  • Have a look at data attributes available in HTML5 https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes – P Fuster Sep 05 '19 at 09:25
  • @PFuster Thanks for the suggestion. I personally don't like using data attributes. I don't like having to put `data-` in front of every attribute. It's just a personal style preference. – Moshe Sep 05 '19 at 09:37

0 Answers0