ReactJs import dynamic components in reactjs reactjs import css,reactjs import component,reactjs import image,reactjs

fairly new to react.js, but prototyping a concept and getting stuck.

I want to have a component that delivers a variable name back (that it gets from an API), then based on that name, import a bunch of files that would share the same name in a folder structure, i.e.;

Folder structure

src/components/test/comp1.js
src/components/test/comp2.js

Then in my App component

import GetName from './components/apiRequest.GetName';
import Comp1 from './components/<GetName />/comp1';

Were GetName would deliver 'test' - But i can't do this, i just get a 'failed to compile' - any ideas on where i'm going wrong?

Answer:1



  1. reactjs import css
  2. reactjs import component
  3. reactjs import image
  4. reactjs import json file
  5. reactjs import file outside src
  6. reactjs import js file
  7. reactjs import svg
  8. reactjs import as

I want to use leader-line in my React web project. It is an external javascript library, but I don't know how to integrate it into the project with the JSX syntax. For example, its documentation tells ...

I want to use leader-line in my React web project. It is an external javascript library, but I don't know how to integrate it into the project with the JSX syntax. For example, its documentation tells ...

Background (possibly irrelevent): I have a large react project I'm changing gulp -> webpack. It's isomorphic so I'm using webpack-isomorphic-tools. So I have this line which no longer works: const ...

Background (possibly irrelevent): I have a large react project I'm changing gulp -> webpack. It's isomorphic so I'm using webpack-isomorphic-tools. So I have this line which no longer works: const ...