I have a component renders other ones by switch-case
export default function Fragment(props) {
switch (props.type) {
case FRAGMENT_TYPES.Start:
return StartFragment(props);
case FRAGMENT_TYPES.Rules:
return RulesFragment(props);
// some other cases
default:
return null;
}
}
But I get 'order of Hooks error' if StartFragment uses hooks but RulesFragment doesn't.
How can I avoid this error? Should I raise all hooks up in Fragment or there is another method?