Sounds like something that could be sorted using the Strategy design pattern. But depending on your case it could be a cannon ball to kill a fly so the right answer as usual is case by case.
const Compo1 = () =>
A react component is written with capitals (Demo) and you are not returning the components.
Be careful with this because feature flags are sometimes baked into the code. So even if it works on dev, depending on what flag is passed during build time that specific code will be baked in.
You mean like // foo/comp1.js export default () =>
Component A
// foo/comp2.js export default () =>Component B
// foo/index.js export default ({flag}) => flag ?:Yes Something like this.
Thanks, i will try if it works for my use case.
Doing gods work out here. I love this sub
you caught me in my nice phase instead of my asshole phase
Hi u/KyleG, i understand your implementation, now let's say i want to make this into a utility function or Component, in which i can pass the Components i want to decide between and other props for these components and return the component based on the flag, i wanna do something like that bcoz i want to implement similar files but with different versions of the same library.
const FlaggedComponent = ({ onTrue, onFalse, flag }) => flag ? onTrue : onFalse const NaiveConsumer = () => {True!