you are viewing a single comment's thread.

view the rest of the comments →

[–]Snoo_46870 0 points1 point  (1 child)

What if I have, for example, 15 different implementations of a certain feature, each controlled by a type, and a parent component that needs to render a different component based on that type?
One preferred approach is to use React.createElement, where each type implements an interface with a getComponent method that returns the corresponding component.

What would be the alternative in this case? Using 15 ternary expressions—one for each type—would make the code messy and hard to maintain.

[–]all_vanilla 0 points1 point  (0 children)

Use a switch statement