Migrating create-react-app from javascript to typescript

UPDATE: create-react-app version 2.1.0 support typescript so for those of you who are starting from scratch you can use it to create new application with typescript, and according to the documentation it should be done with the following command: $ npx create-react-app my-app –typescript For existing projects, after updating to version 2.1.0, add the following … Read more

create-react-app Typescript 3.5, Path Alias

In my case ,i solved this issue using craco and craco-alias Install craco and craco-alias : npm install @craco/craco –save && npm i -D craco-alias Create tsconfig.paths.json in root directory { “compilerOptions”: { “baseUrl”: “./src”, “paths”: { “@components/*” : [“./components/*”] } } } Extend tsconfig.paths.json in tsconfig.json { “extends”: “./tsconfig.paths.json”, //default configs… } Create craco.config.js … Read more

Warning: validateDOMNesting(…): cannot appear as a descendant of

This is the code which causing the error, <NavLink href=”#x”><Link id=”RouterNavLink” style={None} to=”/contact”>anywords</Link></NavLink> Which is converted to, <a><a></a></a> So you are getting error, Warning: validateDOMNesting(…): <a> cannot appear as a descendant of <a> To solve this just use one of the follow, <NavLink id=”RouterNavLink” style={None} to=”/contact”>anywords</NavLink> OR, <Link id=”RouterNavLink” style={None} to=”/contact”>anywords</Link>

What is the react-app-env.d.ts in a react typescript project for

This file references TypeScript types declarations that are specific to projects started with Create React App. These type declarations add support for importing resource files such as bmp, gif, jpeg, jpg, png, webp, and svg. That means that the following import will work as expected without errors: import logo from ‘./logo.svg’; It also adds support … Read more