@18f/redux-textarea-debounce 中文文档教程

发布于 3年前 浏览 27 项目主页 更新于 3年前

redux-textarea-debounce

模拟

Installation

npm i @18f/redux-textarea-debounce

Usage

无论您作为 onChange 道具提供什么功能,都会去抖动,因此它只会 最多每 200 毫秒运行一次。 只要用户继续输入,它就不会运行 根本-除非他们放慢足够长的时间。

它尽可能像一个普通的 textarea

import TextArea from '@18f/redux-textarea-debounce';

function handler(e) {
  // You get the full SyntheticEvent object, but
  // not on every change - at most once every 200ms
  console.log(e.target.value);
}

render() {
  return (
    <TextArea value="initial value" onChange={handler} />
  );
}
PropTypeDescription
valuestringThe initial text value of the text area.
namestringA name for the component, passed down to the underlying <textarea> - this will show up on the event as event.target.name.
onChangefunctionThe event handler for change events, called at most once ever 200ms. Receives one argument, a React SyntheticEvent from the underlying real <textarea> component.

Public domain

这个项目在全球范围内公共领域。 如中所述 CONTRIBUTING

这个项目在美国属于公共领域,并且 全球作品的版权和相关权利通过 CC0 1.0 通用公共领域贡献

所有对该项目的贡献都将在 CC0 奉献精神下发布。 通过提交拉取请求,您同意遵守此放弃 版权权益。

redux-textarea-debounce

A React component that emulates a <textarea> but debounces the onChange event, which is especially useful for redux apps. If you try to handle every onChange by routing it through the dispatcher and all that fun stuff, your app may begin to lag. This app helps with that!

Installation

npm i @18f/redux-textarea-debounce

Usage

Whatever function you provide as the onChange prop is debounced so it only runs at most once every 200ms. As long as the user keeps typing, it won't run at all - unless they slow down long enough.

It's as much like a regular textarea as possible:

import TextArea from '@18f/redux-textarea-debounce';

function handler(e) {
  // You get the full SyntheticEvent object, but
  // not on every change - at most once every 200ms
  console.log(e.target.value);
}

render() {
  return (
    <TextArea value="initial value" onChange={handler} />
  );
}
PropTypeDescription
valuestringThe initial text value of the text area.
namestringA name for the component, passed down to the underlying <textarea> - this will show up on the event as event.target.name.
onChangefunctionThe event handler for change events, called at most once ever 200ms. Receives one argument, a React SyntheticEvent from the underlying real <textarea> component.

Public domain

This project is in the worldwide public domain. As stated in CONTRIBUTING:

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文