@kne/use-blur

0.1.0 • Public • Published

useBlur

复合表单组件控制blur事件

npm i @kne/use-blur

使用说明

import useBlur from '@kne/use-blur';

const SomeComponent = ()=>{
  const ref = useBlur(()=>{
    console.log('onBlur trigger');
  });
  return (
    <span ref={ref}>
      <input type="text"/>
      <input type="text"/>
    </span>
  );
};

上述示例组件中,SomeComponent组件中的任何一个元素触发focus然后点击组件外部区域都会触发onBlur,而在两个input之间来回focus不会触发onBlur

一般用于捕捉form的复合组件形成的field的校验时机

Dependencies (1)

Dev Dependencies (9)

Package Sidebar

Install

npm i @kne/use-blur

Weekly Downloads

1

Version

0.1.0

License

ISC

Unpacked Size

27.5 kB

Total Files

11

Last publish

Collaborators

  • metacoo
  • yangwang123456
  • juliewang
  • lingtong