Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing error: Identifier 'React' has already been declared

Tags:

reactjs

I m trying to import component but i m not able to do it

I have also tried export default class App extends React.Component instead of class App extends Component() but it is not solving my problem

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


class App extends Component() {
  constructor(props){

  }
  render() {
  return (
    <div className="App">
      <table className="titleBar">
        <tbody>
          <tr>
            <td>
              <img alt="app icon" width="50" src="primary_green.svg"/>
            </td>
            <td width="8"/>
            <td>
              <h1>MovieDb Search</h1>
            </td>
          </tr>
        </tbody>
      </table>
      <input style={{
        fontSize: 24,
        display: 'block',
        width: '99%',
        paddingTop: 8,
        paddingBottom: 8,
        paddingLeft: 16
      }} placeholder="Enter Search Term"/>
    </div>
  );
 }
}

export default App;


Line 2:  Parsing error: Identifier 'React' has already been declared

import React from 'react';
import React,{Component} from 'react';
import './App.css';
like image 472
sushmita kumari Avatar asked Oct 29 '25 01:10

sushmita kumari


1 Answers

On the top of code snippet React is imported twice

import React from 'react';
import React,{Component} from 'react';

It should be

import React, {Component} from 'react';
like image 106
frontendgirl Avatar answered Oct 30 '25 13:10

frontendgirl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!