react-simpletabs icon indicating copy to clipboard operation
react-simpletabs copied to clipboard

Tab component reverts to first tab whenever parent component renders

Open matthewgertner opened this issue 10 years ago • 9 comments

I'm embedding your component in another React component. Every time I emit a change event in one of the tabs, the tab component displays the first tab. The problem seems to be the componentWillReceiveProps method. It always sets the state to the "new" tabActive property even if it is the same as the old tabActive property. As a result, if you don't pass in the prop explicitly, it reverts to the default value on every render. Wouldn't it be better to have the following?

  componentWillReceiveProps: function(newProps){
    if(newProps.tabActive && newProps.tabActive !== this.props.tabActive){
      this.setState({tabActive: newProps.tabActive})
    }
  }

Or am I misunderstanding something?

matthewgertner avatar Apr 28 '15 15:04 matthewgertner

+1

ustccjw avatar May 20 '15 08:05 ustccjw

+1

theogravity avatar Jul 16 '15 23:07 theogravity

@matthewgertner Given that the author has been unresponsive for months, may I ask you to publish your PR as a node module (eg react-simpletabbed)?

theogravity avatar Jul 22 '15 00:07 theogravity

+1

maccman avatar Jul 29 '15 06:07 maccman

@pedronauck Making a last effort to get your attention. Any chance you can accept the PR and publish a new NPM package?

matthewgertner avatar Jul 29 '15 09:07 matthewgertner

~~@matthewgertner fork his version on your repo, tag it and use the tar package in your package.json~~

Got confused with who was unresponsive :D

dmatteo avatar Jul 30 '15 12:07 dmatteo

@matthewgertner I think it's safe to fork and publish a new one.

theogravity avatar Aug 04 '15 05:08 theogravity

Okay I'll get it done this week.

matthewgertner avatar Aug 04 '15 10:08 matthewgertner

:+1:

theogravity avatar Aug 04 '15 17:08 theogravity