Wiki
Here, we will discuss the problems and solutions that we have encountered in the development process.
Support for TypeScript 5.x
in Create React App
In the https://github.com/1chooo/1chooo.com/pull/76, when I tried to upgrade the react-scripts
to 5.x
, I got the following error:
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: react-scripts@5.0.1
npm error Found: typescript@5.5.4
npm error node_modules/typescript
npm error typescript@"^5.5.4" from the root project
npm error peer typescript@">= 2.7" from fork-ts-checker-webpack-plugin@6.5.3
npm error node_modules/fork-ts-checker-webpack-plugin
npm error fork-ts-checker-webpack-plugin@"^6.5.0" from react-dev-utils@12.0.1
npm error node_modules/react-dev-utils
npm error react-dev-utils@"^12.0.1" from react-scripts@5.0.1
npm error node_modules/react-scripts
npm error react-scripts@"5.0.1" from the root project
npm error 1 more (tsutils)
npm error
npm error Could not resolve dependency:
npm error peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1
npm error node_modules/react-scripts
npm error react-scripts@"5.0.1" from the root project
Add the following to the package.json
to solve the problem: 1
+ "overrides": {
+ "typescript": "^5.5.4"
+ },
[!IMPORTANT] The version of
overrides
must be the same as the version of TypeScript independencies
.
- Goodbye create-react-app
- Why is create-react-app still used by many? Very important #12628
- I’m trying to deploy my react app with vercel. I did every step in my terminal but at the end get error “Error: Command “npm install” exited with 1”
- Start a New React Project
- How can I get a compatible React package ecosystem having both react-scripts@x and typescript@^5?
Migrate from Create React App to NextJS
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
$ npm uninstall react-scripts
$ npm uninstall react-router-dom
$ npm install next
- Migrating from Create React App to NextJS: A Practical Guide
- Migrating from create-react-app to Vite: A Quick and Easy Guide
- Migrating from Create React App
- Replace Create React App recommendation with Vite #5487
- CreativeTechGuy/ReactTemplate
- How to Migrate from create-react-app to Vite using Jest and Browserslist
- Migrating from Create React App
Dangerously Set innerHTML
In HTML, <div> cannot be a descendant of <p>.
This will cause a hydration error.
...
<Markdown>
<p>
^^^
<http://localhost:3000/_next/static/chunks/src_dd03ef._.js:150:225>
<div>
+ const isImageNode = (node: any): node is Element => {
+ return node && node.type === 'element' && node.tagName === 'img';
+ };
const MarkdownRenderer: React.FC<MarkdownRendererProps> = ({ content }) => (
<ReactMarkdown
remarkPlugins={[remarkGfm]}
rehypePlugins={[rehypeRaw]}
components={{
+ p: ({ node, children }) => {
+ const hasImage = node && node.children && node.children.some(isImageNode);
+ if (hasImage) {
+ return <>{children}</>;
+ }
+ return <p>{children}</p>;
+ },
...
>
{content}
</ReactMarkdown>
);
export default MarkdownRenderer;
Next.js Image Fast Loading
- Build an Image Compressor with Next.js
- Next JS Image Optimization: Best Practices for Faster Loading
- 14 Best Practices For Next JS Speed Optimization
SEO Tools
Open Graph Meta Tags
Loose Autocomplete
acceptString = (str: "foo" | "bar" | (string & {})) => {
console.log(str);
};
acceptString("baz");
https://www.youtube.com/live/8HoOxOd86M4?t=2778&si=P2mxsBXVq8UmrAX_