I am looking to render a component based upon a string. Essentially, I am hoping to find the JSX equivalent to JavaScript's dynamic function name ability (parent["childMethod"]
).
So, if I have a string, such as "<MyComponent />"
, how can I turn into JSX and render?
React.createElement
, store that element in a variable, and include the element within some JSX using curly braces. If you have the entire JSX code for an element in a string, though, like"<MyComponent />
, you need another solution that I don't know.