如何去除多个可点击按钮的抖动

How to debounce multiple clickable buttons

目前我正在使用 lodash library 去抖动...

<Button
  onPress={_.debounce(
        () => {
               navigation.goBack()
              },
              500,
              {
                leading: true,
                trailing: false,
               }
   )}
   title="Back"
/>

当我只点击一个 link 时,它按预期工作,但如果我像这样点击两个可点击区域...(见下面的 gif)会发生以下情况...

从 "render" 方法中移动 debounced 函数的定义,如下所示:

export default class YourClassName extends Component {
  constructor() {
    super();

    this.debouncedOnPressHandler = _.debounce(
      () => { navigation.goBack() },
      500,
      {
        leading: true,
        trailing: false,
      }
    )
  }

  render() {
    return (
      <div>
        <Button onPress={this.debouncedOnPressHandler} title="Back A" />
        <Button onPress={this.debouncedOnPressHandler} title="Back B" />
      </div>
    );
  }
}