P
P
Polina Titova2022-02-08 11:44:29
JavaScript
Polina Titova, 2022-02-08 11:44:29

How to import data correctly?

Import data and pass to components:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/app/App';
import { tickets } from './data/tickets.json';

ReactDOM.render(
  <React.StrictMode>
    <App tickets={tickets} />
  </React.StrictMode>,
  document.getElementById('root')
);

The data is displayed in cards, but an error was displayed in the console:
ERROR in ./src/index.tsx 11:13-20
Should not import the named export 'tickets' (imported as 'tickets') from default-exporting module (only default export is available soon)

How should I import the data correctly so that no errors are displayed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question