Georg Unterholzner @georg.dev · Mar 5

Alternatively, I could think of restricting the child components' type (it’s a TypeScript library anyway). Then, I could inject the property into the child, and it would just automagically work. I’ve done this countless times in Angular libs. I'm not sure if this is a thing in React, though. 🤷

0 likes 1 replies

?

Replies

Georg Unterholzner · Mar 5

Honestly, I don't particularly like any of these options. The property injection leads to a neat API but might be hard to grasp and error-prone. Using context is not as pretty but ok. Using a callback just feels off. I'd love to hear your thoughts! Did I miss something? Which one would you choose?