![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
前端
文章平均质量分 80
_葱
这个作者很懒,什么都没留下…
展开
-
【React Scheduler源码第三篇】React Scheduler原理及手写源码
手写react scheduler源码,彻底搞懂什么是任务切片,什么是时间切片,以及为什么使用MessageChannel而不是setTimeout实现任务调度原创 2022-09-07 22:26:58 · 485 阅读 · 1 评论 -
【React Scheduler源码第二篇】React Scheduler用法详解
React Scheduler 基础用法,高优先级任务如何插队,长任务如何切片,任务切片如何中途取消,任务过期等基础知识,为后续手写scheduler源码奠定坚实的基础原创 2022-09-05 21:23:43 · 628 阅读 · 0 评论 -
【React Scheduler源码第一篇】哪些API适合用于任务调度
了解屏幕刷新率,了解哪些API 适合用于React Scheduler任务调度。为后续的手写scheduler源码奠定基础原创 2022-09-04 23:27:44 · 340 阅读 · 0 评论 -
根据给定数组过滤另一个数组
需求描述:给定一个ids数组: const ids= ['op3', 'op1', 'op2', 'op1']; // ids可能会有重复数据给定一个list数据:const list = [ { id: 'op8', name: '分类op8'}, { id: 'op7', name: '分类op7'}, { id: 'op6', name: '分类op6'}, { id: 'op5', name: '分类op5'}, { id: 'op3'原创 2021-04-20 11:31:41 · 796 阅读 · 0 评论 -
react结合iframe小实践
通过window.open打开一个新页面,在新的页面里嵌入iframe。路由: <Router history={history}> <Switch> <Route path="/Demo" component={Demo} /> <Route path="/iframeDemo/:id" component={IframeDemo} /> </Switch...原创 2020-07-31 09:28:52 · 1804 阅读 · 0 评论 -
js实现复制并能保留原格式粘贴
使用textarea能粘贴的时候保留原格式。使用input粘贴的时候格式会丢失。 const input = document.createElement('textarea'); document.body.appendChild(input); input.value = “复制我呀”; // input.setAttribute('value', "复制我呀"); input.select(); if (document.原创 2020-07-01 14:05:50 · 2487 阅读 · 0 评论 -
requestAnimationFrame实现js防抖
timer.jsconst hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';const now = hasNativePerformanceNow ? () => performance.now() : () => Date.now();export function cancelTimeout(timeo原创 2020-07-01 11:12:31 · 551 阅读 · 0 评论 -
懒加载
import React, { useRef, useEffect, useState } from 'react';import Item from './item';import styles from './index.module.less';const Home = () => { const [itemsObj, setItemObj] = useState({}); const [prevScrollTop, setPrevScrollTop] = useState(0.原创 2020-06-03 19:18:55 · 248 阅读 · 0 评论 -
React 16.13.1使用useState时会执行两次render的问题
示例使用typescript编写一个简单的hello新建一个Hello.tsx组件:import React, {useState} from 'react'interface IHelloProps { message?: string;}const Hello: React.FC<IHelloProps> = (props) => { console.log('hello before render....') return (原创 2020-05-10 16:13:08 · 9787 阅读 · 0 评论