-
-
Notifications
You must be signed in to change notification settings - Fork 740
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
New dayElement prop #89
Comments
Closing – no need for this. |
Actually i was waiting for this feature 🙄 |
@olegakbarov What is your use-case? |
I just need a custom element instead of |
@olegakbarov what you need the custom element for, if I may ask? |
What about a |
I like this proposal. Currently we are using For Example: class Day extends React.Component {
render() {
const isSelectable = this.props.date > this.props.selectableRangeStart && this.props.date < this.props.selectableRangeEnd;
return <div className={ isSelectable ? 'selectable' : ''}>{this.props.date.getDate()}</div>;
}
} class DateRangePicker extends React.Component {
render() {
return <DayPicker dayClass={Day} dayProps={{ selectableRangeStart: this.state.selectableRangeStart, selectableRangeEnd: this.state.selectableRangeEnd }} />;
}
} |
With the question raised by @boatkorachal and solved with #179 my conclusion is that we should go with <DayPicker
dayElement={ day =>
<Day selectableRangeStart={this.state.selectableRangeStart} selectableRangeEnd={this.state.selectableRangeEnd} />
}
/> Yet not sure about the signature of the dayElement function yet :) What do you think? |
In your example |
No,
If this is your issue, then you can do it also with const renderDayFactory = (start, end) => day =>
<MyCustomDayContent day={day} selectableRangeStart={start} selectableRangeEnd={end} />
// later, in your render() method
<DayPicker renderDay={ renderDayFactory(this.state.selectableRangeStart, this.state.selectableRangeEnd) } /> Perhaps I don't understand your case? |
That’s what we are currently doing. But I want to avoid creating new functions during rendering. |
@lo1tuma The issue is old and maybe its scope is not clear: basically the idea behind the Maybe it is possible to solve the problem you are rising with a different API. I don't understand why you are using <DayPicker
modifiers={{
selectable: day => day > this.state.selectableRangeStart && day < this.props.selectableRangeEnd;
}}
/> which adds already the |
Agreed, so basically my use case is to improve rendering performance. Initially we used modifiedr functions (4 of them) even with memoization. We render 12 months at once. On iOS (mobile safari) and old android devices rendering took serveral seconds (~2 to 5 seconds). Whenever the user interacts with our date range picker, we need the change the modifier functions (=> creating new functions) in order to trigger re-rendering of the |
Sure, let's move the discussion here #181. Thanks for the numbers 👍 |
This prop should replace the current
renderDay
prop (that should become deprecated) and accept a React Element that will receive theday
prop, e.g.(this will supersede #50)
The text was updated successfully, but these errors were encountered: