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

Determining the availability of props.visible #95

Open
devdammit opened this issue Aug 23, 2017 · 4 comments · May be fixed by #111
Open

Determining the availability of props.visible #95

devdammit opened this issue Aug 23, 2017 · 4 comments · May be fixed by #111

Comments

@devdammit
Copy link

Hello Guys! I noticed that you check the props.visible by the presence of it in props.
Why not check for undefined?

if ('visible' in this.props) {

We use a rule eslint - react/require-default-props. And set props.visible as undefined in the defaultProps. And if the props.visible is equal to undefined, then he still gets to extraProps.popupVisible.

@benjycui
Copy link
Member

But why, are you going to lint code in node_modules.

@devdammit
Copy link
Author

@benjycui, No, of course, we do not check node_modules into the style code. :)
We have our UIkit, and we made a wrapper for rcTooltip. In this wrapper we describe props

@benjycui
Copy link
Member

Why not check for undefined?

Yep, you can PR.

But I don't agree with this ESLint rule, we can set default prop for defaultXXX, but I don't think we should set default props for controlled props(e.g. value, visible..)

@oldwin
Copy link

oldwin commented Nov 29, 2017

@benjycui I agree with @mochachai, need to check it for undefined. For example in my case I need to use rc-tooltip in two different scenes inside the one component.

  1. Will work like a standard tooltip
  2. Will show preview with always opened tooltip

So I was going to just pass true or undefined in 'visible' props, but now I have to do one trick:

const props = {};
if (preview) {
  props.visible = true;
}

return (
  <Tooltip placement="bottom" {...props} />
)

@devdammit devdammit linked a pull request Dec 25, 2017 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants