Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React: How to I get a React component button to lose focus?

Tags:

reactjs

When I click on a pagination button, the focus state stays in the browser after the page updates. How to I tell that component to blur?

This is where I'm calling the component.

<Paginate onClick={this.handleButtonClick.bind(this)} text="Prev"/>

This is the component.

import React, { Component } from 'react';

class Paginate extends Component {
  render() {
    const {text} = this.props;

    return(
      <button onClick={this.props.onClick}>{text}</button>
    )
  }
}

export default Paginate;
like image 701
Chris Avatar asked Nov 27 '25 21:11

Chris


1 Answers

Adding to mrossman's comment in the accepted answer, what worked for me was onClick={(e) => e.currentTarget.blur()}.

like image 156
3 revs Avatar answered Nov 29 '25 15:11

3 revs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!