E
E
Evgeny Kramor2018-03-05 19:37:30
React
Evgeny Kramor, 2018-03-05 19:37:30

How to import multiple components from app.js in react?

There is app.js which contains two components:

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

class App extends Component {
  
  render() {
    return (
      <div className="app">
        какой-то текст.
      </div>
    );
  }
}

export default App;

class Gap extends Component {
  
  render() {
    return (
      <div className="apps">
        какой-то текст 2
      </div>
    );
  }
}

and index.js file:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import {Gap} from './App';
import registerServiceWorker from './registerServiceWorker';


ReactDOM.render(<App/> , document.getElementById('root'));

registerServiceWorker();

how do i render the Gap component?
The question is rather too primitive, but at the output I can not get the desired result.
That is, App -> id root
and Gap in id example.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-03-05
@exgod

app.js
In general, Gap is better to take out in a separate file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question