Material UI error while using Grid in React

Viewed 324

Code of Login Component:

import Grid from '@material-ui/core/Grid';
import Paper from '@material-ui/core/Paper';

const Login=()=>{
    return (
        <Grid>
            <Paper>
                Sign in
            </Paper>
        </Grid>
    )
}

export default Login

Code for App.js

import './App.css';
import Login from './components/Login';
function App() {
  return (
    <div className="App">
      <Login></Login>     
    </div>
  );
}

export default App;

Code for app.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';


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

reportWebVitals();

Error

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
1 Answers
Related