I want to put variables(in loop) to call const name, which I imported from other file.
I want to import const from file like this:
export const p6_q1="AAA";
export const p6_q2="BBB";
export const p6_q3="CCC";
export const p6_q4="DDD";
I've tried this :
import React from 'react';
import * as Text from 'textKorean';
const FaqItem = ({obj}) => {
return (
<div>
{console.log(obj)}
{ Text.p6_q`${String(obj)}` }
</div>
);
};
export default FaqItem;
props 'obj' is well presented on my console. But the error message says:
./src/FaqItem.js Attempted import error: 'p6_q' is not exported from 'textKorean' (imported as 'Text').
I want it to be p6_q1. p6_q2, p6_q3, ... and so on.
but my code in
{ Text.p6_q`${String(obj)}` } says it is just
p6_q.
How can I do that?
p6_q${String(obj)}] } (there are back ticks after the open bracket and before the close bracket){console.log(obj)}{ Text[`p6_q${String(obj)}`] }