nickeljew/react-month-picker

Ability to hide and show without needing a ref

Closed this issue · 2 comments

As refs require a class (or some crazy trickery), it would be great if there were a show prop that could be set to true to show the picker and false to hide it.

While I still feel like this isn't idiomatic React, it does seem to work

const MyComponent = ({value}) => {
    let picker = null
    return (<MonthPicker ref={ref => picker = ref}>
      <div onClick={() => picker && picker.show()}>
        ...
      </div>
    </MonthPicker>)
}

please check v1.3.1