after installing MUI : Invalid hook call - reactjs

Hello I started recently using MUI. I wanted to use one of the Icons and after using : npm install #mui/material #emotion/react #emotion/styled
[Invalid hook error1
I'm currently using React 18.2.0
and this is the first time this error showed to me
even after installing npm install #mui/icons-material
Same thing

Related

Not able to install #mui/icons-material through npm

Not able to install #mui/icons-material
When I try to install material ui icons dependency it got stuck for a long time showing like this:
# client**>npm install #mui/icons-material
[##############....] \ reify:fsevents: sill reify mark deleted [
I also cleared the cache using npm cache clean --force but it didn't work.
How can I come out of this problem?
Install Material UI core
npm install #mui/material #emotion/react #emotion/styled
After installing it install the icons package by running
npm install #mui/icons-material
If you have material-ui/core v4 upgrade it to the latest one and for that, you also need to update react to at least v17 because the minimum requirement for v5 of material-ui is v5.

Why Is Mui No Longer Installing?

I am trying to use mui select in my React App. After using
npx create-react-app .
I then use
npm install #mui/material #emotion/react #emotion/styled
to install mui.
After following the steps to install Mui I am getting this error:
Could not resolve following dependency: peer react#"^17.0.0" from #mui/material#5.5.3
but it is apparently installed in the package.json:
"dependencies": {
..
"react": "^18.0.0",
..
}
If anyone could help me figure out what's going on here, I'd sure appreciate it.
MUI seems to be not ready for React Version 18.
The error message says, that Material UI Version 5.5.3 (which is the latest as of 2022-03-31) needs React with major version number 17 as peer dependency.
I hope someone has a better answer, but as of now it seems that we have to wait until the version number of React as peer dependency gets bumped to 18.0.0.
Current progress of the MUI project
Edit: following this Answer you should be able to get it working by using the --legacy-peer-deps flag
npx create-react-app test
cd test
npm install #mui/material #emotion/react #emotion/styled --legacy-peer-deps

Cannot use MUI 'ContentCopy' icon

I am trying to use the icon 'ContentCopy' from MUI.
https://mui.com/components/material-icons/ says to use the following import:
import ContentCopyIcon from '#mui/icons-material/ContentCopy';
No matter what I do, I get the error:
Module not found: Can't resolve '#mui/icons-material/
I have already tried the following:
npm install #material-ui/core
npm install #material-ui/icons
I also tried deleting my node-modules and re-running npm install.
Any ideas on what else I could try??
It seems that you confused of using version 4 and 5.
You need to install the icons of version 5.
npm install #mui/icons-material
And import the icon from the module.
import ContentCopyIcon from '#mui/icons-material/ContentCopy';
Please refer to this.
to version 5 you need to install mui
npm install #mui/icons-material
mui contains all the icons
from '#mui/icons-material/_';
info https://www.npmjs.com/package/#mui/icons-material

React Typescript: It looks like you're trying to use TypeScript but do not have typescript installed

I want to create a React application and I want to use a typescript in this application, at first I went to the React website in order to create an application using typescript and I found that I had to put this instruction in the terminal first:
npx create-react-app my-app --template typescript
And when it finished installing, I put it in the terminal:
npm start
But I got this error:
It looks like you're trying to use TypeScript but do not have typescript installed
I opened the terminal and wrote this instruction:
npm install
then i run the app:
npm start
But the error is still there
How can I solve the problem?
I solved my problem with the following instruction:
npm install --save typescript #types/node #types/react #types/react-dom #types/jest
or
yarn add typescript #types/node #types/react #types/react-dom #types/jest
have you tried
npm install -g typescript
yes i tryed but still with error
Have you tried
npm run start
Consider upgrading Next.js 11 to 12 or to latest version. Also, you need to upgrade types to latest for react and react-dom. Here is a brief documentation about that:
https://nextjs.org/docs/upgrading#upgrade-nextjs-version-to-12

React (typescript version) app build by create-react-app breaks when I install material-UI

I first used the command npx create-react-app my-app --template typescript to make a react application, which worked fine and there was no error in the console. then I executed npm install #material-ui/core to install material UI and after installing material-UI my react application starts showing the following error
Could not find a declaration file for module 'react'. 'C:/Users/91727/OneDrive/Desktop/test/node_modules/react/index.js' implicitly has an 'any' type.\n If the 'react' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react`
Could not find a declaration file for module 'react/jsx-runtime'. 'C:/Users/91727/OneDrive/Desktop/test/node_modules/react/jsx-runtime.js' implicitly has an 'any' type.\n If the 'react' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react`
As suggested in conversation about this issue, try to install #material-ui/core with --legacy-peer-deps option:
npm install --save --legacy-peer-deps #material-ui/core

Resources