React Hooks的几个注意事项
- 很多时候,input只关心最后状态,不需要用useState
- 有时候并不需要用useEffect去改变值
- useMemo防止object在重新渲染时再内部值不变时被更换内存地址,变成新“值”
- 适时终止过时的api请求
https://www.npmjs.com/package/bignumber.js
import BigNumber from "bignumber.js"
console.log( new BigNumber('123456789.7654321').toFormat(2) )
输出:123,456,789.77
Add custom.d.ts to ./scr
declare module '*.svg' {
import React = require('react')
export const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
const src: string
export default src
}
Import svg on your page
import { ReactComponent as IconLogo } from '../assets/images/logo.svg'
Usage
<IconLogo height='10' />