镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Determining the availability of props.visible #95

Open

Description

@devdammit

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.

Activity

  1. benjycui commented on Aug 24, 2017

    @benjycui
    Member

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

  2. devdammit commented on Aug 24, 2017

    @devdammit
    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

  3. benjycui commented on Aug 25, 2017

    @benjycui
    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..)

  4. oldwin commented on Nov 29, 2017

    @oldwin

    @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} />
    )
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions