0

I am following this: https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Client-side_JavaScript_frameworks/React_getting_started

Which clearly says that the component won't work without the first import listed

import React from 'react';
import logo from './logo.svg';
import './App.css';

I just created my first tutorial app, opened App.js and it is not there. Yet I can npm start run it without any problems.

mLstudent33
  • 1,033
  • 3
  • 14
  • 32

1 Answers1

1

There are three import statements.

import React from 'react';
Stackoverflow already has a bunch of questions with answers about it (as an example: JSX can be used without importing React). Short answer: this import can be missed since React 17.

import logo from './logo.svg';
Here is an assignment of some value to the logo variable (by Webpack); therefore, the logo will be undefined if this import is missed. Apparently, your application can successfully start with an undefined logo.

import './App.css';
This import adds some styles to a component (by Webpack). So, your application has default browser styles without it.

That's why your application can be started without these import statements.