Skip to content

Commit

Permalink
fix: Adjust default for onError of the provider to log errors corre…
Browse files Browse the repository at this point in the history
…ctly (#46)
  • Loading branch information
amannn authored Aug 2, 2021
1 parent 15c1574 commit d0a1986
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/use-intl/src/IntlProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Props = {
* 2. It will be returned as a static value from the `useNow` hook. Note
* however that when `updateInterval` is configured on the `useNow` hook,
* the global `now` value will only be used for the initial render, but
* afterwards the current date will be retunred continuously.
* afterwards the current date will be returned continuously.
*/
now?: Date;
};
Expand All @@ -51,9 +51,13 @@ function defaultGetMessageFallback({
return [namespace, key].filter((part) => part != null).join('.');
}

function defaultOnError(error: IntlError) {
console.error(error);
}

export default function IntlProvider({
children,
onError = console.error,
onError = defaultOnError,
getMessageFallback = defaultGetMessageFallback,
...contextValues
}: Props) {
Expand Down

0 comments on commit d0a1986

Please sign in to comment.