score:0

Accepted answer

i was not able to find perfect solution but workaround mentioned below was good enough for me to achieve what i was looking for.

i have created common table headers index file which contains all locations for table headers:

tableheaders.jsx

let tablelheaders = {};

tableheaders['propa'] = require('../tablea/tableaheaders.jsx').default;
tableheaders['propb'] = require('../tableb/tablebheaders.jsx').default;
tableheaders['propc'] = require('../tableb/tablecheaders.jsx').default;
...
tableheaders['propx'] = require('../tablex/tablexheaders.jsx').default;

export default tableheaders

and then in the view for the main component specify prop for that:

<mytable tableheaders="propa" />

and in the mytable component access it as require instead of import

mytable.jsx:

import tableheaders from "tableheaders.jsx;

....


const tablecolumns = tablelheaders[props.tableheaders];

hope it will helps someone else or somebody else will came up with better solution.


Related Query

More Query from same tag