Commit 707abd00 authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

feat(widgets): ensure passed locale is supported (#3245)

* ensure passed locale is supported

* warn on locale mismatch

* export SUPPORTED_LOCALES
parent 2efc1fb3
import { SUPPORTED_LOCALES } from 'constants/locales'
import { WidgetProps } from 'lib/components/Widget' import { WidgetProps } from 'lib/components/Widget'
import { IntegrationError } from 'lib/errors' import { IntegrationError } from 'lib/errors'
import { PropsWithChildren, useEffect } from 'react' import { PropsWithChildren, useEffect } from 'react'
...@@ -18,5 +19,12 @@ export default function WidgetsPropsValidator(props: PropsWithChildren<WidgetPro ...@@ -18,5 +19,12 @@ export default function WidgetsPropsValidator(props: PropsWithChildren<WidgetPro
} }
}, [width]) }, [width])
const { locale } = props
useEffect(() => {
if (locale && locale !== 'pseudo' && !SUPPORTED_LOCALES.includes(locale)) {
console.warn('Unsupported locale: ', locale)
}
}, [locale])
return <>{props.children}</> return <>{props.children}</>
} }
import Swap, { SwapProps } from './components/Swap' import Swap, { SwapProps } from './components/Swap'
import Widget, { WidgetProps } from './components/Widget' import Widget, { WidgetProps } from './components/Widget'
export { SUPPORTED_LOCALES } from 'constants/locales'
type SwapWidgetProps = SwapProps & WidgetProps type SwapWidgetProps = SwapProps & WidgetProps
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment