Skip to content
New issue

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

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

Already on GitHub? # to your account

SingleDatePicker rerendering due to state.dayPickerContainerStyles #1699

Closed
aaronbabaron opened this issue Jun 20, 2019 · 1 comment · Fixed by #1735
Closed

SingleDatePicker rerendering due to state.dayPickerContainerStyles #1699

aaronbabaron opened this issue Jun 20, 2019 · 1 comment · Fixed by #1735

Comments

@aaronbabaron
Copy link

react-dates version
20.2.4

Describe the bug

I'm trying to make rendering/rerendering of two separate singledatepickers faster, but it seems like dayPickerContainerStyles on the state is causing it to rerender regardless of what's going on.

Screen Shot 2019-06-20 at 1 06 44 PM

Steps to reproduce the behavior:

          <SingleDatePicker
            customInputIcon={
              <SomeIcon />
            }
            inputIconPosition="after"
            date={date}
            focused={this.state.isEndDateFocused}
            id="some_end_date_id"
            onDateChange={(date: Moment | null) => {
              //something here
            }}
            onFocusChange={this.setFocus.bind(this, 'END')}
            placeholder="End Date"
          />
@mmarkelov
Copy link
Contributor

@aaronbabaron there is one possible not the best updating of state, that I see:
https://github.com/airbnb/react-dates/blob/121fc443631efaea3e2dbee80a5695c0666599ea/src/components/SingleDatePicker.jsx#L305-L309
This function run on resize event and when focused is changing. So my thoughts not to run setState in this function when dayPickerContainerStyles is empty. I can do PR, maybe it will help

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

Successfully merging a pull request may close this issue.

2 participants