Skip to content
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

Merge object passed to localeUtils with Utils #46

Closed
gpbl opened this issue Jul 31, 2015 · 4 comments
Closed

Merge object passed to localeUtils with Utils #46

gpbl opened this issue Jul 31, 2015 · 4 comments

Comments

@gpbl
Copy link
Owner

gpbl commented Jul 31, 2015

No description provided.

@gpbl gpbl modified the milestone: v2.0.0 Oct 11, 2015
@gpbl
Copy link
Owner Author

gpbl commented Oct 18, 2015

I should extract from Utils those function first, otherwise there's the risk a developer would overwrite functions used internally. So Utils should be renamed LocaleUtils, while addons/LocaleUtils should be renamed MomentUtils (or something like that). The internal functions could be moved to Helpers.

@gpbl gpbl removed this from the v2.0.0 milestone Nov 3, 2015
@gpbl
Copy link
Owner Author

gpbl commented Nov 3, 2015

Starting from v1.1, a way for solving this issue is to extends the default localeUtils, e.g.:

import { localeUtils } from "react-day-picker/utils";
function formatMonthTitle() {
 return "Custom Month Title"
}

<DayPicker localeUtils={{ ...LocaleUtils, formatMonthTitle }} />

@gpbl gpbl closed this as completed Nov 3, 2015
@bvaughn
Copy link

bvaughn commented Nov 6, 2015

FWYI, (since you pointed to this example in the release notes), I think your example is actually the opposite of what you meant. I think you want...

import { localeUtils } from "react-day-picker/utils";
function formatMonthTitle() {
 return "Custom Month Title"
}

<DayPicker localeUtils={{ ...LocaleUtils, formatMonthTitle }} />

(The custom formatMonthTitle should come after the spread, or it will be overridden by the defaults.)

@gpbl
Copy link
Owner Author

gpbl commented Nov 6, 2015

Thanks! I fixed the comment 👍

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

No branches or pull requests

2 participants