score:0

you cannot instantiate a react element directly from a string, you will have to maintain a mapping from strings to react classes.

const map = { "componenta" : componenta }

// render
<map[match.params.topicid] />

score:0

if you have a component for each case of match.params.topicid you can build a dictionary that maps the values of topicid to their respective component.

for example, if you have two possible values for topicid that are topicid1 (associated to topicid1 component) and topicid2 (associated to topicid2 component) you could render your component with the following code:

const topicsmap = {
    topicid1: topicid1,
    topicid2: topicid2
};
const topic = ({ match }) => {
    const topicid = topicsmap[match.params.topicid] || topiciddefault;

    return (
        <div>
            <h3>{match.params.topicid}</h3>
            <topicid />
            <companydashboardmain/>
            <companyaccdetailsmain/>
        </div>
    );
};

note that i am defining a default component topiciddefault just in case the match.params.topicid does not match any of the expected values (topicid1 and topicid2).


Related Query

More Query from same tag