@tntd/hooks
v1.0.5
Published
react hooks组件
Downloads
7
Readme
react hooks组件库
安装
npm install @tntd/hooks --save
import { Button, Switch } from 'antd';
import { useToggle } from "@tntd/hooks";
export default () => {
const [state, { toggle }] = useToggle();
return (
<div>
<p>
Effects:
<Switch checked={state} onChange={toggle} />
</p>
<p>
<Button type="default" onClick={() => toggle()}>Toggle</Button>
<Button type="danger" onClick={() => toggle(false)}>Toggle False</Button>
<Button type="primary" onClick={() => toggle(true)}>Toggle True</Button>
</p>
</div>
);
}
支持按需加载(推荐)
安装babel插件
npm install babel-plugin-tnt --save-dev
.babelrc中添加如下配置即可
"plugins": [
[
"babel-plugin-tnt",
{
"library": ["@tntd/hooks"]
}
],
]