Coder
Coder

Reputation: 1

Cannot import a component by typing

When I am importing a module in reactjs by typing import React, from 'react';` in from it is showing me error and the code won't work but if I copy paste it the code works perfectly...

What might be the reason ?

Upvotes: 0

Views: 67

Answers (3)

Ltwoz
Ltwoz

Reputation: 24

just only React no comma

import React from 'react';

Upvotes: 0

Erba Afidotama
Erba Afidotama

Reputation: 81

If you just want import react, use this:

import React from "react";

no need coma

Upvotes: 0

Behrad Hajmiri
Behrad Hajmiri

Reputation: 260

It is enough to write like this:

import React from 'react';

and if you want to import more modules, you can do like this example:

import React, { useState, useEffect } from 'react';

Upvotes: 2

Related Questions