• Stars
    star
    799
  • Rank 57,011 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Collection of react hooks

React Hooks

This is a collection of frequently used react hooks to support development within baidu, contributions from community are also welcomed.

Project structure

This is a typical pnpm workspace based monorepo, each hook creates a package in packages folder, the folder name is dash-cased and without the use prefix.

Package name must comform a format of @huse/foo-bar.

Each package should named export at least one hook like:

import {useInputValue} from '@huse/input-value';

Unit tests are recommended, they are placed inside src/__tests__ folder with an extension of .test.js, we highly recommend a 100% of branch coverage.

Document

By now we are unable to publish document online since docz build fails, you can find description to package in its README.md, or to start a document site locally.

pnpm install
npm run doc:dev

Open http://localhost:3000 to view documents about hooks.

All hooks

Hook Description
useActionPending Add a pending indicator to any async function
useBoolean Methods to control a boolean state
useSwitch More convenient way to use boolean state
useToggle More convenient way to toggle boolean state or setState directly
useClickOutside Trigger callback when clicks outside a specific element
useArray Methods to control array state
useSet Methods to control Set state
useMap Methods to control Map state
useDebouncedEffect Debounce an effect on value change
useDebouncedValue Debounce a value change
useDebouncedCallback Debounce a callback function
useRenderTimes Return times of component rendered
useChangeTimes Return times of a value changed
useUpdateCause Observe the cause of component update
useDerivedState Derive a state from external prop
useDocumentEvent Add listeners to document's event
useDocumentTitle Change document.title
useEffectRef More reliable function based ref with clean-up ability
useElementResize Trigger callback when element resize
useElementSize Return element's size
useHover Observe mouse enter and leave to element
useImmerReducer A useReducer with immer support (deprecated)
useImmerState A useState with immer support (deprecated)
useInfiniteScroll Encapsulate methods and props to implement infinite scroll
useInputValue Bound a value and it's change handler to input element
useOnScreenCallback Trigger callback when element intersects with viewport
useOnScreen Return whether element intesects with viewport
useOnScreenLazyValue Lazy initialize a value when it intersects with viewport
useLocalStorage Visit and update local storage
useMedia Return whether a media query is currently matched
usePreferDarkMode Return whether user prefers dark color scheme
useMergedRef Merge multiple ref into a single one
useMethodsNative Wrap methods around a state
useMethodsExtensionNative Wrap methods around a setState function
useMethods useMethodsNative with immer support
useMethodsExtension useMethodsNative with immer support
useOnLine Return user is current online of offline
useCounter Methods to control a number state with increment and decrement
usePerformanceTiming Collect performance data and send to callback
useLayoutTiming Collect timings of a component's layout
usePoll Periodically trigger an async function and manage its response
usePreviousValue Get previous version of a value
usePreviousEquals Return whether a value is equals to that on previous render
useOriginalCopy Track back a value to get a reference equals copy when content are identical
useOriginalDeepCopy useOriginalCopy with deep equal support
useRequestCallback Return a function to trigger request with its data, error and pending state
useRequest Trigger request on params change and return its data, error and pending state
useScript Load an external script
useScriptSuspense Load an external script with suspense
useScrollIntoView Scroll an element into viewport
useScrollLock Lock scroll of document
useScrollPosition Get current scroll top and left
useScrollTop Get current scroll top
useScrollLeft Get current scroll left
useSelection Manage state to work with list selection, including multiple and range selection
useSnapshotState Get a state with undo and redo support
useTimeout Trigger callback after specified time
useInterval Trigger callback periodically
useStableInterval useInterval but counts ellapsed time of function execution, both sync and async
useTransitionState A state which will revert back to its initial value when updated
useForceUpdate Force update a component
useWindowSize Get the size of window
useOptimisticFactory Infrastructure hook to create optimistic state
useOptimisticState Optimistic state
useOptimisticTask Wrap async task to have optimistic result
useUserMedia Open video and audio streams in browser
useNavigate Get a function to navigate to any location
useLocationState Wrap location's state into a react state
useSearchParams Parse search string to URLSearchParams as well as a function to update search
useSearchParam Get a single search param
useSearchParamAll Get a single search param as array
useUpdateSearchParams Get a function to update search params
useSearchParamState Wrap a single search param into a react state
useWebSocket Create a web socket connecting to specified url

More Repositories

1

vue-echarts

Vue.js component for Apache ECharts™.
JavaScript
9,615
star
2

echarts-for-weixin

基于 Apache ECharts 的微信小程序图表库
JavaScript
6,880
star
3

zrender

A lightweight graphic library providing 2d draw for Apache ECharts
TypeScript
5,816
star
4

fontmin

Minify font seamlessly
JavaScript
5,545
star
5

spec

This repository contains the specifications.
4,595
star
6

echarts-gl

Extension pack for Apache ECharts, providing globe visualization and 3D plots.
JavaScript
2,554
star
7

echarts-wordcloud

Word Cloud extension based on Apache ECharts and wordcloud2.js
JavaScript
1,592
star
8

echarts-liquidfill

Liquid Fill Chart for Apache ECharts
JavaScript
1,407
star
9

fonteditor

在线字体编辑器
JavaScript
1,297
star
10

awesome-echarts

Awesome list of Apache ECharts
1,269
star
11

veui

Enterprise UI for Vue.js.
JavaScript
1,057
star
12

esl

enterprise standard loader
JavaScript
834
star
13

fontmin-app

fontmin as an OS X, Linux and Windows app
HTML
665
star
14

fecs

Front End Code Style Suite
JavaScript
643
star
15

echarts-stat

Statistics tool for Apache ECharts
HTML
570
star
16

edp

ecomfe develop platform
JavaScript
546
star
17

etpl

ETPL是一个强复用、灵活、高性能的JavaScript模板引擎,适用于浏览器端或Node环境中视图的生成。
JavaScript
496
star
18

okam

Mini program development framework
JavaScript
416
star
19

react-native-cn

407
star
20

est

EFE Styling Toolkit based on Less
Less
398
star
21

saber

移动 Web 解决方案
CSS
358
star
22

esui

enterprise simple ui library
JavaScript
340
star
23

er

enterprise ria framework
JavaScript
301
star
24

knowledge

Front-end knowledge hierarchy
CoffeeScript
236
star
25

reskript

一个帮助开发React应用的全功能命令行套件
TypeScript
210
star
26

rider

Rider 是一个基于 Stylus 与后处理器、无侵入风格的 CSS 样式工具库
CSS
205
star
27

echarts-map-tool

Map Tool for Apache ECharts
JavaScript
130
star
28

js-native

JavaScript
116
star
29

uioc

IoC Framework for us
JavaScript
115
star
30

eslint-config

eslint shareable config for efe
JavaScript
111
star
31

san-cli

A CLI Tooling based on San.js for rapid development.
JavaScript
98
star
32

san-mui

A Set of SAN Components that Implement Google's Material Design
JavaScript
95
star
33

ub-ria

RIA base for union business
JavaScript
94
star
34

react-kiss

A simple and stupid react container solution
JavaScript
85
star
35

react-suspense-boundary

A boundary component working with suspense and error
TypeScript
84
star
36

san-xui

A Set of SAN UI Components that widely used on Baidu Cloud Console
JavaScript
81
star
37

gulp-fontmin

Minify font seamlessly
JavaScript
80
star
38

echarts-optimizer

JavaScript
79
star
39

santd

San UI Toolkit for Ant Design
TypeScript
76
star
40

moye

A Simple UI Library for ZX
JavaScript
74
star
41

ecomfe.github.io

https://efe.baidu.com
JavaScript
72
star
42

react-track

A declarative, component based solution to track page views and user events with react & react-router
TypeScript
71
star
43

echarts-graph-modularity

Graph modularity extension for community detection with Apache ECharts
HTML
70
star
44

tempad-dev

Inspect panel on Figma, for everyone.
Vue
67
star
45

diffy-update

Scripts to update object or array with a diff output
JavaScript
54
star
46

gitdiff-parser

A fast and reliable git diff parser.
HTML
53
star
47

learn-graphql-cn

Learn GraphQL 中文翻译
48
star
48

standard-redux-shape

A library to help standardize your redux state shape
JavaScript
47
star
49

htmlcs

HTML Code Style
JavaScript
46
star
50

saber-showcase

使用 saber 创建的 WebApp 示例
JavaScript
41
star
51

smarty4js

a JavaScript template most like smarty, use smarty module in javascript
JavaScript
34
star
52

rebas

Node framework for Saber, base on Express
JavaScript
34
star
53

baidubce-sdk

Baidu Cloud Engine Node.js SDK
JavaScript
28
star
54

node-csshint

Csshint your css code
JavaScript
27
star
55

amd-analyzer

JavaScript
26
star
56

echarts-bmap

HTML
26
star
57

light-dls

Front-end assets and tooling for Baidu Light DLS.
Less
25
star
58

san-loader

San-Loader 是基于 webpack 的工具,允许开发者书写 San 单文件的方式来进行组件开发。
JavaScript
25
star
59

redux-optimistic-thunk

redux-thunk like dispatching with optimistic UI supported
JavaScript
25
star
60

zrender-doc

Document for zrender
JavaScript
22
star
61

grapher.js

JavaScript 3D Plot Library
JavaScript
21
star
62

redux-managed-thunk

A redux-thunk compatible middleware with managed feature to help write more controllable and reusable thunks
JavaScript
20
star
63

efe

EFE guide
20
star
64

mini-event

A simple and dedicated library to provide event related components
JavaScript
18
star
65

veui-theme-blue

a theme for VEUI
Less
18
star
66

esui-family

Online Demo and document of ESUI Family
JavaScript
18
star
67

dls-icons

Icons for Baidu Light DLS.
JavaScript
17
star
68

echarts-gallery-feedback

Official Feedback Repository for ECharts Gallery
16
star
69

edp-webserver

Package for edp webserver.
JavaScript
16
star
70

san-realworld-app

An exemplary real-world application built with San. This is a good example to discover San for beginners.
JavaScript
16
star
71

san-transition

Append transition effects for elements in san components.
JavaScript
16
star
72

node-lesslint

Less lint
JavaScript
15
star
73

ef

ef is a integration framework with er & esui
JavaScript
14
star
74

echarts-builder-web

ECharts online builder
JavaScript
14
star
75

saber-ajax

适用于移动端、promise 风格的 ajax 封装
JavaScript
13
star
76

san-anode-utils

Util Functions for San ANode
JavaScript
13
star
77

promise

A promise respecting ES standard with plenty of handy extensions
JavaScript
12
star
78

saber-env

移动端浏览器环境检测
JavaScript
12
star
79

echarts-dagre

ECharts graph layout extension using dagre.js
JavaScript
12
star
80

aop

Aspect oriented programming utilities
JavaScript
12
star
81

sublime-etpl

An ETPL syntax definition & snippets specifically for Sublime Text.
Python
12
star
82

bat-ria

RIA extensions for Brand Ads
JavaScript
11
star
83

deep-grasp

A toolkit for adopting LLM into your existing app.
TypeScript
11
star
84

ub-ria-ui

UI components for ub ria applications - standardized & implemented
JavaScript
11
star
85

edp-build

Package for edp build.
JavaScript
10
star
86

webpack-auto-cdn-plugin

Webpack plugin to automatically extract dependencies and reference them via CDN
JavaScript
10
star
87

stylelint-config

Standard stylelint config for efe team
JavaScript
10
star
88

saber-promise

适合移动端的 Promise/A+ 实现
JavaScript
10
star
89

rider-ui

基于 rider 的 UI 样式库,用于快速构建移动应用界面
CSS
9
star
90

saber-router

适用于移动端的路由控制,支持 hash, popstate
JavaScript
9
star
91

saber-scroll

为移动端页面提供区域滚动功能
JavaScript
9
star
92

blog

Blog
CSS
9
star
93

html-nest-rule

JavaScript
8
star
94

veui-docs

Documentation website for VEUI.
JavaScript
8
star
95

saber-matchmedia

移动端 matchMedia 支持
JavaScript
8
star
96

eicons

ecom public web font icons
CSS
8
star
97

query-shape

Standard utilities to manage query requests and responses
JavaScript
8
star
98

esf

EFE Style Framework
CSS
8
star
99

saber-dom

一个适用于移动端、静态函数风格的DOM工具库
JavaScript
7
star
100

svg-mixed-loader

Webpack loader resolving svg into url string and multiple component formats.
JavaScript
7
star