react-ihooks
v0.2.7
Published
react函数库
Downloads
64
Maintainers
Readme
API文档
安装
npm install react-ihooks
Demo
设置浏览器页面标题Demo:
useDocumentTitle
demo
import React from 'react';
import { useDocumentTitle } from 'react-ihooks';
export default () => {
useDocumentTitle('页面标题');
return (
<div>
<p>为页面设置标题</p>
</div>
);
};
useDebounce
定制处理防抖: ·动态设置等待时间 ·是否开启在延迟开始前调用函数 ·是否开启在延迟开始后调用函数 ·最大等待时间
import React, { useState } from 'react';
import { useDebounce } from 'react-ihooks';
export default () => {
const [value, setValue] = useState<string>();
const debouncedValue = useDebounce(value, { wait: 200 });
return (
<div>
<input
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder="请输入信息"
style={{ width: 380 }}
/>
<p style={{ marginTop: 16 }}>DebouncedValue: {debouncedValue}</p>
</div>
);
};
技术交流
欢迎关注“前端早茶”,与广东靓仔技术交流~