Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
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.
{ Text.p6_q`${String(obj)}` }
p6_q
How can I do that?
First of all, you should probably change the import to import * as Text from './textKorean.js', if the textKorean file is in the same folder as your FaqItem. Next, is your obj is an array, you'll have to map the array. You should try
import * as Text from './textKorean.js'
obj
{ obj.map(num => Text["p6_q"+num])}
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.