@react-aria/i18n
Advanced tools
Comparing version 3.0.0-nightly.676 to 3.0.0-nightly.677
var _intlMessageformat = $parcel$interopDefault(require("intl-messageformat")); | ||
var { | ||
useIsSSR | ||
} = require("@react-aria/ssr"); | ||
var _react2 = require("react"); | ||
@@ -80,2 +84,3 @@ | ||
function $c53c7d716f930bd5da78e9efb99e3e$export$useDefaultLocale() { | ||
let isSSR = useIsSSR(); | ||
let [defaultLocale, setDefaultLocale] = useState($c53c7d716f930bd5da78e9efb99e3e$var$currentLocale); | ||
@@ -95,3 +100,12 @@ useEffect(() => { | ||
}; | ||
}, []); | ||
}, []); // We cannot determine the browser's language on the server, so default to | ||
// en-US. This will be updated after hydration on the client to the correct value. | ||
if (isSSR) { | ||
return { | ||
locale: 'en-US', | ||
direction: 'ltr' | ||
}; | ||
} | ||
return defaultLocale; | ||
@@ -101,7 +115,3 @@ } | ||
const $aa95c2b730b505b265f124d9aec67193$var$I18nContext = _react.createContext(null); | ||
/** | ||
* Provides the locale for the application to all child components. | ||
*/ | ||
function I18nProvider(props) { | ||
@@ -108,0 +118,0 @@ let { |
import _intlMessageformat from "intl-messageformat"; | ||
import { useIsSSR } from "@react-aria/ssr"; | ||
import _react, { useEffect, useState, useContext, useCallback, useRef } from "react"; | ||
@@ -65,2 +66,3 @@ | ||
function $e851d0b81d46abd5f971c8e95c27f1$export$useDefaultLocale() { | ||
let isSSR = useIsSSR(); | ||
let [defaultLocale, setDefaultLocale] = useState($e851d0b81d46abd5f971c8e95c27f1$var$currentLocale); | ||
@@ -80,3 +82,12 @@ useEffect(() => { | ||
}; | ||
}, []); | ||
}, []); // We cannot determine the browser's language on the server, so default to | ||
// en-US. This will be updated after hydration on the client to the correct value. | ||
if (isSSR) { | ||
return { | ||
locale: 'en-US', | ||
direction: 'ltr' | ||
}; | ||
} | ||
return defaultLocale; | ||
@@ -86,7 +97,3 @@ } | ||
const $cff8541df3b5c83067b2ab3ee0d20$var$I18nContext = _react.createContext(null); | ||
/** | ||
* Provides the locale for the application to all child components. | ||
*/ | ||
export function I18nProvider(props) { | ||
@@ -93,0 +100,0 @@ let { |
{ | ||
"name": "@react-aria/i18n", | ||
"version": "3.0.0-nightly.676+8c55251a", | ||
"version": "3.0.0-nightly.677+63f8d9f8", | ||
"description": "Spectrum UI components in React", | ||
@@ -21,3 +21,4 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@react-types/shared": "3.0.0-nightly.676+8c55251a", | ||
"@react-aria/ssr": "3.0.0-nightly.2355+63f8d9f8", | ||
"@react-types/shared": "3.0.0-nightly.677+63f8d9f8", | ||
"intl-messageformat": "^2.2.0" | ||
@@ -31,3 +32,3 @@ }, | ||
}, | ||
"gitHead": "8c55251ab2fb481dd8573b47d23dd99f259063b9" | ||
"gitHead": "63f8d9f8fcca05aeec4711d3568f0ddd684c748a" | ||
} |
@@ -16,2 +16,3 @@ /* | ||
import {useEffect, useState} from 'react'; | ||
import {useIsSSR} from '@react-aria/ssr'; | ||
@@ -50,3 +51,4 @@ export interface Locale { | ||
*/ | ||
export function useDefaultLocale() { | ||
export function useDefaultLocale(): Locale { | ||
let isSSR = useIsSSR(); | ||
let [defaultLocale, setDefaultLocale] = useState(currentLocale); | ||
@@ -69,3 +71,12 @@ | ||
// We cannot determine the browser's language on the server, so default to | ||
// en-US. This will be updated after hydration on the client to the correct value. | ||
if (isSSR) { | ||
return { | ||
locale: 'en-US', | ||
direction: 'ltr' | ||
}; | ||
} | ||
return defaultLocale; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
103979
943
5