项目的src目录下创建declaration.d.ts declare module "*.png"; declare module "*.svg"; declare module "*.jpeg"; declare module "*.jpg"; 引用 https://stackoverflow.com/questions/71099924/cannot-find-module-file-name-png-or-its-corresponding-type-declarations-type
Category: React
Something about React
React 使用ts
安装ts npm i typescript ts-loader 配置tsconfig.json { "compilerOptions": { "outDir": "./dist/", "noImplicitAny": true, "module": "es6", "target": "es5", "jsx": "react-jsx", "allowJs":… Read more
React using “use-immer”
Using immer to manage object. import React from "react"; import { useImmer } from "use-immer"; function App() { const [person,… Read more
React how to call child function?
Use the "useImperativeHandle" Parent file: import {useRef,useEffect} from 'react' import RankingPopup from '@/components/popups/Ranking' export default function(){ const RankingPopupRef = useRef(null)… Read more
How to get get current route in React Router
Using useLocation import * as React from 'react'; import { useLocation } from 'react-router-dom'; function App() { let location =… Read more
How to build a base React H5 project.
1. Initialization & Install Dependencies Initial the project > npm init Install base dependencies > npm i webpack webpack-cli webpack-dev-server… Read more