Could not find a declaration file for module 'react-reveal/Fade' - reactjs

I want to use react-reveal package in my react project. I installed it. But react can not find module
Could not find a declaration file for module 'react-reveal/Fade'.
But react-reveal shows in package.json file and node module.
"dependencies": {
"#testing-library/jest-dom": "^5.14.1",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^12.8.3",
"bootstrap": "^4.6.0",
"jquery": "^3.6.0",
"react": "^17.0.2",
"react-bootstrap": "^1.6.1",
"react-dom": "^17.0.2",
"react-parallax": "^3.3.0",
"react-reveal": "^1.2.2",
"react-router-bootstrap": "^0.25.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-scroll": "^1.8.2",
"react-water-wave": "^1.0.5",
"web-vitals": "^1.1.2"
},
I tried to install npm i --save-dev #types/react-reveal.
Then this error comes
'#types/react-reveal#latest' is not in the npm registry.
How can I solve this?
Note: I am not using typescript

Use require to import the package
import "./Product.scss"
//use require to import the module
const Fade = require("react-reveal/Fade")
export interface IProduct {
price: number
title: string
img: string
}
const Product: React.FC<IProduct> = ({ price, title, img }) => {
return (
<Fade bottom cascade>
<li className="product-wrapper">
<div className="product-container">
<img src={`${img}`} alt="" />
<div className="main-details">
<div className="title">{title}</div>
<div className="details">
<div className="price">Price: $ {price}</div>
<div className="button-wrapper">
<button className="button btn-primary">
Add to cart
</button>
</div>
</div>
</div>
</div>
</li>
</Fade>
)
}
export default Product
Tried this implementation and it worked

Run this commands without typescript
nom install react-reveal
npm install react-reveal/Fade --save
OR
import { Fade } from 'react-reveal';

Related

Uncaught TypeError: Cannot read properties of null (reading 'useContext') when using MUI

Why do I keep encountering this error when using the Grid of MUI in my react component
this is the whole code of the component
import React from "react";
import Grid from "#mui/material/Grid";
const Footer = () => {
return (
<footer>
<Grid container spacing={2}>
<Grid item xs={6} md={8}>
hasdsadsa
</Grid>
</Grid>
</footer>
);
};
export default Footer;
but once I comment the Grid Tag below the program runs fine
package.json
"dependencies": {
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.4.0",
"#testing-library/user-event": "^13.5.0",
"bootstrap": "^5.2.2",
"react": "^18.2.0",
"react-bootstrap": "^2.5.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.4.2",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},

Font Awesome icons on React Js Project

According to Font Awesome documentation, I followed this example below but didn't get any result. I used font awesome a lot of time on my html project in the past. But this is for the first time I am using it on my React Application. How can I get the icons from font awesome on my react application?
import React from 'react'
import { FontAwesomeIcon } from '#fortawesome/react-fontawesome'
export const Beverage = () => (
<div>
<FontAwesomeIcon icon="check-square" />
Your <FontAwesomeIcon icon="coffee" /> is hot and ready!
</div>
)
There is my package.json dependencies.
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^6.1.2",
"#fortawesome/free-solid-svg-icons": "^6.1.2",
"#fortawesome/react-fontawesome": "^0.2.0",
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.3.0",
"#testing-library/user-event": "^13.5.0",
"axios": "^0.27.2",
"bootstrap": "^5.2.0",
"formik": "^2.2.9",
"jquery": "^3.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.2",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"redux": "^4.2.0",
"redux-thunk": "^2.4.1",
"web-vitals": "^2.1.4"
}
https://github.com/FortAwesome/react-fontawesome
Commands : install fontawesome & react-fontawesome
$ npm i --save #fortawesome/fontawesome
$ npm i --save #fortawesome/react-fontawesome
$ npm i --save #fortawesome/fontawesome-free-solid
$ npm i --save #fortawesome/fontawesome-free-regular
$ npm i --save #fortawesome/fontawesome-svg-core
then in your component app.
import React, { Component } from 'react';
import { FontAwesomeIcon } from '#fortawesome/react-fontawesome'
import { faCoffee } from '#fortawesome/fontawesome-free-solid'
export const Beverage = () => (
<div>
Your <FontAwesomeIcon icon={faCoffee} />is hot and ready!
</div>
)

How can Tailwind/typography work well with markdown-it in a React project?

I'm attempted to develop a new feature for my blog, that is a Markdown editor for writing articles.
I chosed #tailwindcss/typography and markdown-it to do that, so this is my whole dependencies:
package.json
{
"dependencies": {
"firebase": "^9.0.0-beta.7",
"markdown-it": "^12.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0"
},
"devDependencies": {
"#babel/core": "^7.15.0",
"#babel/preset-env": "^7.15.0",
"#babel/preset-react": "^7.14.5",
"#tailwindcss/typography": "^0.4.1",
"autoprefixer": "^10.3.2",
"babel-loader": "^8.2.2",
"css-loader": "^6.2.0",
"dotenv-webpack": "^7.0.3",
"html-webpack-plugin": "^5.3.2",
"postcss": "^8.3.6",
"postcss-cli": "^8.3.1",
"postcss-loader": "^6.1.1",
"style-loader": "^3.2.1",
"tailwindcss": "^2.2.7",
"webpack": "^5.51.1",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^4.0.0"
}
}
Below code is the component for this feature, including a editing area and a preview area. However, it didn't work.
When I run this code, it is rendered out like this, without typographing the <h1> tag.
However, if I repalce md.render(markdown) with <h1>hello</h1>(the markdown-it's rendering result), it seems "work", looking like this.
Editor.jsx
import React, { useState } from "react";
const md = require("markdown-it")('commonmark');
const Editor = () => {
const [markdown, setMarkdown] = useState("# hello");
const onTextChange = (e) => {
setMarkdown(e.target.value);
}
return (
<div>
<form>
<textarea onChange={(e) => onTextChange(e)}>
{markdown}
</textarea>
</form>
<div id="preview" className="prose">
{md.render(markdown)} {/* <h1>hello</h1> */}
</div>
</div>
)
}
export default Editor;
Why these things happened? and how can I make it run with expections?
use react-markdown instead of markdown-it
here is an example:
import ReactMarkdown from "react-markdown";
<div className="prose">
<ReactMarkdown>{markdown}</ReactMarkdown>
</div>
it will render the provided content as DOM in the page, and Tailwind/typography perfectly styles those elements.

Attempted import error: 'fade' is not exported from '#material-ui/core/styles'

Tried every possible solutions I found in internet. I upgraded all the dependencies and packages using yarn - below from package.json
"dependencies": {
"#date-io/date-fns": "^1.3.13",
"#date-io/moment": "^1.3.13",
"#material-ui/core": "^5.0.0-beta.2",
"#material-ui/icons": "^5.0.0-beta.1",
"#material-ui/lab": "^5.0.0-alpha.41",
"#material-ui/pickers": "^4.0.0-alpha.12",
"#material-ui/styles": "^5.0.0-beta.2",
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"axios": "^0.21.1",
"date-fns": "^2.22.1",
"moment": "^2.29.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
}
Before upgrading packages I used:
import {
MuiPickersUtilsProvider,
KeyboardDatePicker,
} from '#material-ui/pickers';
After then I imported these:
import LocalizationProvider from '#material-ui/lab/LocalizationProvider';
import AdapterDateFns from '#material-ui/lab/AdapterDateFns';
and tried below code:
<LocalizationProvider dateAdapter={AdapterDateFns}>
<Grid container justifyContent="space-around">
<DatePicker
disableToolbar
variant="inline"
format="DD/MM/yyyy"
margin="normal"
label="Date"
name="date"
value={values.date}
onChange={(date) => handleInputChange(convertToDefault(date))}
/>
</Grid>
</LocalizationProvider>
Can you help me out? It's quite hassle :/
use this version works fine for me...yarn add #material-ui/core#4.11.4 #material-ui/pickers
"#material-ui/core": "4.11.4",
"#material-ui/pickers": "^3.3.10",
- import { fade } from '#material-ui/core/styles';
+ import { alpha } from '#material-ui/core/styles';
const classes = makeStyles(theme => ({
- backgroundColor: fade(theme.palette.primary.main, theme.palette.action.selectedOpacity),
+ backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity),
}));
Hi I don't think it's a part of #material-ui/pickers any more.
You can check this https://github.com/mui-org/material-ui-pickers/issues/2157
For me its working fine with exact these version. Use the exact same versions and thanks me later. If it not allowed you installation then use --force flag.
"#material-ui/core": "^4.11.4",
"#material-ui/pickers": "^3.3.10",
You cannot use 'fade' from material-ui anymore, as this is deprecated. You can use 'alpha' instead.

A problem with Material UI - Module not found: Can't resolve '#material-ui/icons/Add'

I am having problem with material ui. It worked for my first two projects but suddenly now its showing this error:
Module not found: Can't resolve '#material-ui/icons/Add' in
'E:\Projects\Slack-clone\slack-clone\src'
This is one of my components:
import React from 'react';
import "./Header.css";
import { Avatar } from '#material-ui/core';
import AddIcon from '#material-ui/icons/Add';
function Header() {
return (
<div className="header">
<div className="header_left">
<Avatar className="header_avatar" alt="soham bhosale" src=""/>
<AddIcon />
</div>
and this is my package.json after installing material-ui:
{
"name": "slack-clone",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.10",
"#testing-library/react": "^11.2.6",
"#testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.1"
}
Try this
npm install #material-ui/icons
And after that please check package.json you will find your package and after that you can try like this import AccessAlarmIcon from '#material-ui/icons/AccessAlarm';

Resources