From 9766fe6d4bb1a7e68b3925d00a2edc5d27c72fbd Mon Sep 17 00:00:00 2001 From: Kyle Rosenberg Date: Tue, 30 Aug 2022 15:28:26 -0500 Subject: [PATCH] [fix] Export useLocaleContext as default export Close #2389 --- .../src/__tests__/__snapshots__/index-test.js.snap | 6 ++++-- .../src/__tests__/index-test.js | 6 ++++-- .../react-native-web/src/exports/useLocaleContext/index.js | 3 ++- packages/react-native-web/src/index.js | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/babel-plugin-react-native-web/src/__tests__/__snapshots__/index-test.js.snap b/packages/babel-plugin-react-native-web/src/__tests__/__snapshots__/index-test.js.snap index 9fa795d9..5b3a1fbb 100644 --- a/packages/babel-plugin-react-native-web/src/__tests__/__snapshots__/index-test.js.snap +++ b/packages/babel-plugin-react-native-web/src/__tests__/__snapshots__/index-test.js.snap @@ -30,11 +30,12 @@ export { default as unstable_createElement } from 'react-native-web/dist/exports `; -exports[`Rewrite react-native to react-native-web import from "native-native": import from "native-native" 1`] = ` +exports[`Rewrite react-native to react-native-web import from "react-native": import from "react-native" 1`] = ` import ReactNative from 'react-native'; import { View } from 'react-native'; import { Invalid, View as MyView } from 'react-native'; +import { useLocaleContext } from 'react-native'; import * as ReactNativeModules from 'react-native'; ↓ ↓ ↓ ↓ ↓ ↓ @@ -43,12 +44,13 @@ import ReactNative from 'react-native-web/dist/index'; import View from 'react-native-web/dist/exports/View'; import { Invalid } from 'react-native-web/dist/index'; import MyView from 'react-native-web/dist/exports/View'; +import useLocaleContext from 'react-native-web/dist/exports/useLocaleContext'; import * as ReactNativeModules from 'react-native-web/dist/index'; `; -exports[`Rewrite react-native to react-native-web import from "native-native": import from "native-native" 2`] = ` +exports[`Rewrite react-native to react-native-web import from "react-native": import from "react-native" 2`] = ` import ReactNative from 'react-native'; import { View } from 'react-native'; diff --git a/packages/babel-plugin-react-native-web/src/__tests__/index-test.js b/packages/babel-plugin-react-native-web/src/__tests__/index-test.js index 4f23067e..84c10eef 100644 --- a/packages/babel-plugin-react-native-web/src/__tests__/index-test.js +++ b/packages/babel-plugin-react-native-web/src/__tests__/index-test.js @@ -4,15 +4,16 @@ const pluginTester = require('babel-plugin-tester').default; const tests = [ // import react-native { - title: 'import from "native-native"', + title: 'import from "react-native"', code: `import ReactNative from 'react-native'; import { View } from 'react-native'; import { Invalid, View as MyView } from 'react-native'; +import { useLocaleContext } from 'react-native'; import * as ReactNativeModules from 'react-native';`, snapshot: true }, { - title: 'import from "native-native"', + title: 'import from "react-native"', code: `import ReactNative from 'react-native'; import { View } from 'react-native'; import { Invalid, View as MyView } from 'react-native'; @@ -39,6 +40,7 @@ export { StyleSheet, Text, unstable_createElement } from 'react-native';`, export { StyleSheet, Text, unstable_createElement } from 'react-native-web';`, snapshot: true }, + // require react-native { title: 'require "react-native"', code: `const ReactNative = require('react-native'); diff --git a/packages/react-native-web/src/exports/useLocaleContext/index.js b/packages/react-native-web/src/exports/useLocaleContext/index.js index acc5ce24..e80b354b 100644 --- a/packages/react-native-web/src/exports/useLocaleContext/index.js +++ b/packages/react-native-web/src/exports/useLocaleContext/index.js @@ -7,4 +7,5 @@ * @flow strict */ -export { useLocaleContext } from '../../modules/useLocale'; +import { useLocaleContext } from '../../modules/useLocale'; +export default useLocaleContext; diff --git a/packages/react-native-web/src/index.js b/packages/react-native-web/src/index.js index 21fbe356..274e40b0 100644 --- a/packages/react-native-web/src/index.js +++ b/packages/react-native-web/src/index.js @@ -77,5 +77,5 @@ export { default as DeviceEventEmitter } from './exports/DeviceEventEmitter'; // hooks export { default as useColorScheme } from './exports/useColorScheme'; -export { useLocaleContext } from './exports/useLocaleContext'; +export { default as useLocaleContext } from './exports/useLocaleContext'; export { default as useWindowDimensions } from './exports/useWindowDimensions';