Why is it so difficult to post on here, everything I type in the title is not accepted so sorry it does not make sense.
Hello everyone! I'm having this 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:
This only seems to happen after I imported material-ui. Im pretty stumped. Here is my code.
import {Container, AppBar, Typography, Grow, Grid} from '@material-ui/core'
import bandmate from './images/bandmate.jpeg'
const App = ()=> {
return (
<Container maxidth = 'lg'>
<AppBar position = 'static' color = 'inherit'>
<Typography varaint = "h2" align = 'center'>BandMate</Typography>
<img src= {bandmate} alt = 'bandmate' height= '60'/>
</AppBar>
</Container>
);
}
export default App;
The solutions I have run into seem to reference webpack, I am not using webpack so I'm not sure where to go with that. I followed the link above and ran this code as instructed and it returned false, meaning I have a duplicate react issue
window.React1 = require('react');
// Add this in your component file
require('react-dom');
window.React2 = require('react');
console.log(window.React1 === window.React2);```
I've seen some people say to try npm link but I cant seem to get that to work either. I ran ```npm link ../myProjectName/client/node_modules/react``` Im not even sure if I am using npm link correctly, but I just get a ton of errors. All of the posts seem to point to this, but I either don't understand what I'm doing or its not the correct solution.
Thank you all in advance for your help, I have been struggling with this for 2 days now with no progress.
Also I'm not sure what is up with my formatting, I thought you open and close with ``` ``` but I guess not.
After I posted this I just uninstalled all of my packages and reinstalled them and it fixed the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.