/*!
 * React Native Globalize
 *
 * Copyright 2015-2020 Josh Swan
 * Released under the MIT license
 * https://github.com/joshswan/react-native-globalize/blob/master/LICENSE
 */
import React, { useEffect, useState } from 'react';
import { createGlobalize } from '../globalize';
import { GlobalizeContext } from '../context';
export const GlobalizeProvider = ({ children, currency: currencyCode = 'USD', locale = 'en', localeFallback: fallback = false, ...options }) => {
    const [globalize, setGlobalize] = useState(() => createGlobalize({
        ...options,
        locale,
        currencyCode,
        fallback,
    }));
    useEffect(() => {
        setGlobalize(createGlobalize({
            ...options,
            locale,
            currencyCode,
            fallback,
        }));
    }, [currencyCode, locale, fallback]);
    return (React.createElement(GlobalizeContext.Provider, { value: globalize }, children));
};
