Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component should set className in render based on this.props.active and not this.state.active. #1

Closed
invalidred opened this issue Jul 5, 2016 · 1 comment

Comments

@invalidred
Copy link

Hi,

Good job on your component.

There is a small issue when I am using your component in my project. The problem is the component should always infer active value from props and not from state.

So it should not be

className={this.state.active ? activeClass : inactiveClass} 

Rather it should be

className={this.props.active ? activeClass : inactiveClass} 

The reason is, we make API calls to get some object and the object's bool value should determine the active state. The objects bool valus is passed through this.props.

@arnthor3
Copy link
Owner

Hi,

Thanks!

I forgot to put it in the readme but you can set the initial state with the active prop. I will update the readme later on today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants