Comments (3)
🤖
The Minified React error #418 is related to an invalid hook call, and error #423 is related to calling a hook from a non-react function or a non-component function.
In the provided context, the useEffect
hook is not being used correctly. Hooks should be called at the top level of the React function, not inside callbacks or loops.
Here's how you can fix the code:
import React, { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import Markdown from 'markdown-to-jsx';
import Main from '../layouts/Main';
const About = () => {
const [markdown, setMarkdown] = useState('');
useEffect(() => {
const fetchMarkdown = async () => {
const res = await import('../data/about.md');
const r = await fetch(res.default);
const text = await r.text();
setMarkdown(text);
};
fetchMarkdown();
}, []); // Add an empty dependency array to ensure this effect runs once on mount
const count = markdown.split(/\s+/)
.map((s) => s.replace(/\W/g, ''))
.filter((s) => s.length).length;
return (
<Main
title="About"
description="Learn about Michael D'Angelo"
>
<article className="post markdown" id="about">
<header>
<div className="title">
<h2><Link to="/about">About Me</Link></h2>
<p>(in about {count} words)</p>
</div>
</header>
<Markdown>
{markdown}
</Markdown>
</article>
</Main>
);
};
export default About;
In this revised code, I've moved the asynchronous operations into a separate async function fetchMarkdown
that is then called from within the useEffect
hook. This ensures that the hook is being called at the top level of the React function, as required by the rules of hooks. The empty dependency array []
passed to useEffect
ensures that the effect only runs once, when the component mounts.
You can find the original code in the src/pages/About.js file in the repository.
Please let me know if you need further assistance.
Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
from personal-site.
🤖
Hello @safwanidrees,
I'm Dosu, a bot designed to assist with this repository. I'm here to help you debug issues, answer questions, and guide you to become a contributor. While we wait for a human maintainer to join us, I'll be working on your issue. Expect a detailed response from me shortly.
from personal-site.
How to fix Minified React error #418; #423; issue in the production build of that repository ?
from personal-site.
Related Issues (20)
- Menu with yellow border on mobile HOT 3
- npm install fails. HOT 3
- PAGES FAILING FOR NEW PACKAGE.JSON HOT 1
- node-sass v4.14.1 incompatible with node 15+
- Making subpages HOT 2
- CSS not rendering
- Is there any way to add link to each project in the project page ??? HOT 2
- ESlint Error on Windows HOT 1
- Migrating from Google Analytics UA to GA4 HOT 1
- Suggestion: Blog/Journal pages HOT 1
- Deploying from a Fork to GH Pages with Workflow HOT 4
- Can't modify Michael's name in navigation bar HOT 1
- Bolder underline for hyperlinks HOT 1
- Deployment timing out HOT 5
- Contribution Instructions HOT 1
- Deployment Instructions HOT 1
- npm build not working HOT 7
- Error -86 on npm run predeploy using react-snap with Puppeteer HOT 2
- Page is showing readme file HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from personal-site.