I'm using React-popper to show a date picker element after clicking a button.
JSX
<Manager>
<Reference>
{({ ref }) => (
<button ref={ref} onClick={this.onDateRangeBtnClick}>click to show</button>
)}
</Reference>
{ReactDOM.createPortal(
<Popper placement="auto-end" >
{({ ref, style, placement, arrowProps, scheduleUpdate }) => (
<div className={`dayPickerOverlay ${this.state.showDatePicker ? "" : "hidden"}`} ref={ref} style={style} data-placement={placement}>
<DateRangePicker />
</div>
)}
</Popper>,
document.querySelector('#root')
)}
</Manager>
When onDateRangeBtnClick
is called after the button was clicked, I want to re-position the Popper element by calling scheduleUpdate
method, but I do not know how to approach this.
How can I expose that specific scheduleUpdate
to be called within the onDateRangeBtnClick
or alternatively how can I conditionally call a function (scheduleUpdate
for this matter) within JSX itself?