I'm open to alternative methods of performing the same task.
I'd like to do something along the lines of the following:
Menu Item 1
Menu Item 2
Menu Item 3
Target(Where component is loaded)
Upon clicking on a menu item, render the associated component inside the target. Is there a way to dynamically load a component? I.e.
<{menuItemName} />
My current methodology of doing this is awful, slow, and cumbersome(and doesn't work), and involves
<li onClick=this.setState({menuItem:"MenuItem1"})>Menu Item 1</li>
<li onClick=this.setState({menuItem:"MenuItem2"})>Menu Item 2</li>
<li onClick=this.setState({menuItem:"MenuItem3"})>Menu Item 3</li>
<{this.state.menuItem} />
I know there must be a better method of doing this, but I don't currently have the React vocabulary to find the solution I'm looking for. I also am aware that setting state in the render method is a big no-no, but I'm struggling to find the alternative.
Thanks for your help.