随记react

react hooks中使用promise.all

useEffect(async () => { const getFirstResponse = async () => { try { return await axios.get('http://first-api', { params: { carId: id }, }); } catch ( ......
promise react hooks all

react-pdf在部分iOS手机上加载pdf失败问题解决

*最近项目快结束了,测试提了一个bug,iOS手机上加载pdf一直在转圈,加载不出来内容。看到这个bug,在电脑上和安卓手机上没有问题,iOS手机中打开确实又问题,初步确定为app问题。我们的项目是集成在客户的app里的,可能是app内的WebView和Safari有一些差异导致的问题。* 1. 首 ......
react-pdf pdf 部分 问题 手机

pdfjs-dist v2.11.338写个react demo

app.jsx ```jsx import './App.css' import * as pdfjs from "pdfjs-dist"; import "pdfjs-dist/web/pdf_viewer.css"; import { useEffect, useRef, useState } ......
pdfjs-dist 11.338 pdfjs react dist

umi-qiankun——子应用vue+element返回主项目react+antdReact,样式丢失问题

参考: [Bug]结合 styled components 使用时 dynamicHeadAppend 存在缺陷 #617 https://github.com/umijs/qiankun/issues/617 qiankun官网 https://qiankun.umijs.org/zh/api/# ......
umi-qiankun 样式 antdReact qiankun element

[React Typescript] Updating the Global Namespace for an Additional Attribute

I want to add a common attribute to dom element globally: <> <div testId="123" /> <audio testId="123" /> <video testId="123" /> <a testId="123" /> <ab ......

随记

### css 1.css设置transform: scale(x)后元素出现偏移 需要设置transform-origin即偏移原点,默认情况,变换的原点在元素的中心点,即是元素X轴和Y轴的50%处 transform-origin属性可以使用一个,两个或三个值来指定,其中每个值都表示一个偏移量。 ......
随记

创建web应用程序,React和Vue怎么选?

React和Vue都是创建web应用程序的绝佳选择。React得到了科技巨头和庞大的开源社区的支持,代码库可以很大程度地扩展,允许你创建企业级web应用程序。React拥有大量合格甚至优秀的开发人员粉丝,可以解决你在开发阶段可能遇到的任何问题。 毫无疑问,React是创建跨平台解决方案的最佳框架。V... ......
应用程序 程序 React web Vue

React Router 6 快速上手

## 1.概述 1. React Router 以三个不同的包发布到 npm 上,它们分别为: 1. react-router: 路由的核心库,提供了很多的:组件、钩子。 2. **react-router-dom:** 包含react-router所有内容,并添加一些专门用于 DOM 的组件,例如 ......
Router React

react-player学习

## 一个适用于 react 的视频插件—react-player ``` 说明文档 转载说明:来源于npm库中的readme.md 侵权删 调试工具地址: https://cookpete.com/react-player 1. 可以自动播放 2. 可以实现画中画、倍速、可控播放等功能 ``` R ......
react-player player react

[React Typescript] ElementType, ComponentType

The ElementTypetype helper is a bit unusal because it accepts some props and derives what types of components would be able to recieve those props. He ......
ComponentType ElementType Typescript React

[React Typescript] JSX.IntrinsicElements

interface IntrinsicElements { // HTML a: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>; abbr: React.Detail ......
IntrinsicElements Typescript React JSX

[React Typescript] React.ReactNode > React.ReactElement = JSX.Element = React.JSX.Element

This is ReactNode: type ReactNode = | ReactElement | string | number | ReactFragment | ReactPortal | boolean | null | undefined This is React.ReactEle ......
React Element ReactElement Typescript JSX

[React Typescript] React namespace

export = React; export as namespace React; declare namespace React { // // React Elements // type ElementType<P = any> = { [K in keyof JSX.IntrinsicEl ......
React Typescript namespace

[React Typescript] Inferring Type Arguments in Curried Hooks

import { DependencyList, useMemo, useState } from "react"; import { Equal, Expect } from "../helpers/type-utils"; const useCustomState = <TValue>(init ......
Typescript Inferring Arguments Curried React

[React Typescript] Function overload in React hook

import { useState } from "react"; import { Equal, Expect } from "../helpers/type-utils"; type UseStateReturnValue<T> = { value: T; set: React.Dispatch ......
React Typescript Function overload hook

react hooks 子传父

父组件中: import React,{useState } from "react"; import HeXiaoDialog from "../components/hexiaoDialog"; //引入的子组件 function ShuoMing(props){ let [flag , set ......
react hooks

react项目搭建-路由封装

router v6 路由统一管理与添加,对是否登录进行判断。 1.使用脚手架创建项目 新建一个文件夹 ,在文件夹内部打开命令行工具。 执行命令:npx create-react-app 项目名字 将项目放在开发工具中,打开项目终端运行项目(npm start / yarn start) 注:npx命 ......
路由 项目 react

React请求机制优化思路

说起数据加载的机制,有一个绕不开的话题就是前端性能,很多电商门户的首页其实都会做一些垂直的定制优化,比如让请求在页面最早加载,或者在前一个页面就进行预加载等等。 ......
思路 机制 React

React面试1

1.什么是虚拟DOM?虚拟DOM是真实DOM在内存中的表示,ul的表示形式保存在内存中,并且与实际的DOM同步,这是一个发生在渲染函数被调用和元素在屏幕上显示的步骤,整个过程被称为调和 2.类组件和函数组件之间的区别是什么?类组件可以使用其他特性,如状态和生命周期钩子,并且他有this 函数组件只能 ......
React

[React Typescript] Discriminated Tuples in Custom Hooks

import { useEffect, useState } from "react"; export type Result<T> = | ["loading", undefined?] | ["error", Error] | ["success", T]; export const useDa ......
Discriminated Typescript Custom Tuples React

一文了解 history 和 react-router 的实现原理

>我们是[袋鼠云数栈 UED 团队](http://ued.dtstack.cn/),致力于打造优秀的一站式数据中台产品。我们始终保持工匠精神,探索前端道路,为社区积累并传播经验价值。 >本文作者:[霜序](https://luckyfbb.github.io/blog) ## 前言 在前一篇文章中 ......
react-router 原理 history router react

[React Typescript] Well typed a React Context provider

import React from "react"; import { Equal, Expect } from "../helpers/type-utils"; const createRequiredContext = <T extends any>() => { const context = ......
React Typescript provider Context typed

[React Typescript] Fixing type inference in a Custom React Hook

// Problem import { useState } from "react"; import { Equal, Expect } from "../helpers/type-utils"; export const useId = (defaultId: string) => { cons ......
React Typescript inference Fixing Custom

Taro react 插件提供外部插件引用

项目结构 projectName |-pages/index |-plugin |-components |-avatar index页面中引用: import Taro from '@tarojs/taro' import { Component, PropsWithChildren } from ......
插件 react Taro

react 状态管理

srore index.tsx import React from 'react'; // 仓库文件桶 import StoreContent from './StoreContent'; import SetDataBtn from './SetDataBtn'; import ShowDataB ......
状态 react

React(涉及基础和Usestate)

# React React是JavaScript的一个类库; ## Rendering User Interfaces [React](https://nextjs.org/learn/foundations/from-javascript-to-react) > To understand how ......
Usestate 基础 React

React-Chat移动端聊天实例|react18 hooks仿微信App聊天界面

基于react18+react-vant+zustand仿微信手机端聊天室ReactChat。 react18-chat 一款使用最新react18.x hooks、zustand搭配react-vant组件库开发的mobile版仿微信界面聊天实例项目。实现了发送图文消息、图片/视频预览、红包/朋友 ......
React-Chat 实例 界面 React react

React和Vue的区别,大家怎么看?

React和Vue都是创建web应用程序的绝佳选择。React得到了科技巨头和庞大的开源社区的支持,代码库可以很大程度地扩展,允许你创建企业级web应用程序。React拥有大量合格甚至优秀的开发人员粉丝,可以解决你在开发阶段可能遇到的任何问题。 ......
React Vue

前端周刊第66期:TypeScript教程、ESM、React泡沫、htmx、测试文章

周刊同步发表于微信公众号“写代码的宝哥”,欢迎各位小伙伴前来关注 😄! ## 快讯 ![](https://img2023.cnblogs.com/blog/3251068/202308/3251068-20230814131754903-946778878.png) - 软一峰老师最近发布了[《 ......
前端 TypeScript 泡沫 周刊 教程

[React Typescript] Generic Inference through Multiple Type Helpers

import { Equal, Expect } from "../helpers/type-utils"; interface Button<T> { value: T; label: string; } interface ButtonGroupProps<T> { buttons: Butto ......