in Education by
My issue is basically this: I have a bunch of svg images all stored in a .js file like this import React from 'react' export const React = () => export const Angular = () => export const JQuery = () => in another component I want to render correct image based on an array, so for instance I have: import {React,Angular,JQuery} from '../svgs' const images = [ 'React','React','JQuery','Angular','JQuery' ] no I want to render each image, actually to do something like this
images.map (image => )
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
you have to make some changes in svgs.js as you are exporting a named constant React again so it will throw duplication error when you import it. import React from 'react' export const react = () => export const angular = () => export const jQuery = () => After that import them where you want import {react, angular, jQuery} from '../svgs' // don't use quotes as it represents string // const images = [ // 'react', 'angular', 'jQuery' // ] const images = [ react, angular, jQuery ] And last use them in jsx render() { return (
// use uppercase letter for React component {images.map((Image, index) => )}
) }

Related questions

0 votes
    My issue is basically this: I have a bunch of svg images all stored in a .js file like this ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 3, 2022 in Education by JackTerrance
0 votes
    This is part of the component : import MyComp from '../../lib/MyComp' const Data = ( { data } ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    This is part of the component : import MyComp from '../../lib/MyComp' const Data = ( { data } ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I'm doing some work in React, and want to be able to auto-expand my custom components so that I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    What are Pure Components in React js1?...
asked Jun 2, 2021 in Education by JackTerrance
0 votes
    How to create components in React?...
asked Jun 2, 2021 in Technology by JackTerrance
0 votes
    What are Higher Order Components in React js?...
asked Dec 5, 2020 in Technology by JackTerrance
0 votes
    How to pass data between react components?...
asked Dec 5, 2020 in Technology by JackTerrance
0 votes
    How can I apply my div position x value to a variable? And how to iterate it in a for loop? ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I have been developing a webpage which uses n number of dropdownlists which are binding dynamically inside a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I've noticed that the chart object has a fontSize property, but just changing it does nothing, even with ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I would like to dynamically assign a class to a specific cell in a table. An object in "cols" ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 21, 2022 in Education by JackTerrance
0 votes
    I would like to dynamically assign a class to a specific cell in a table. An object in "cols" ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    I would like to dynamically assign a class to a specific cell in a table. An object in "cols" ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
...