[fix] Export useLocaleContext as default export

Close #2389
This commit is contained in:
Kyle Rosenberg
2022-08-30 15:28:26 -05:00
committed by Nicolas Gallagher
parent c764f96ef4
commit 9766fe6d4b
4 changed files with 11 additions and 6 deletions

View File

@@ -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';

View File

@@ -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');

View File

@@ -7,4 +7,5 @@
* @flow strict
*/
export { useLocaleContext } from '../../modules/useLocale';
import { useLocaleContext } from '../../modules/useLocale';
export default useLocaleContext;

View File

@@ -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';