Content-Length: 245752 | pFad | https://docs.nativebase.io/migration/v3xtov32
Copyimport {NativeBaseProvider,extendTheme,v3CompatibleTheme,} from 'native-base';// ...const yourCustomTheme = {// ...};<NativeBaseProvidertheme={extendTheme(v3CompatibleTheme, yourCustomTheme)}></NativeBaseProvider>;
Copyconst withFonts = require('next-fonts');const withPlugins = require('next-compose-plugins');const withTM = require('next-transpile-modules')(['native-base','react-native-svg','styled-components','react-native-safe-area-context','@react-aria/visually-hidden','@react-native-aria/button','@react-native-aria/checkbox','@react-native-aria/combobox','@react-native-aria/focus','@react-native-aria/interactions','@react-native-aria/listbox','@react-native-aria/overlays','@react-native-aria/radio','@react-native-aria/slider','@react-native-aria/tabs','@react-native-aria/utils','@react-stately/combobox','@react-stately/radio','react-native-vector-icons',]);module.exports = withPlugins([withTM, [withFonts, { projectRoot: __dirname }]],{webpack: (config) => {config.resolve.alias = {...(config.resolve.alias || {}),// Transform all direct `react-native` imports to `react-native-web`'react-native$': 'react-native-web',};config.resolve.extensions = ['.web.js','.web.ts','.web.tsx',...config.resolve.extensions,];return config;},});
Copyconst { withExpo } = require('@expo/next-adapter');const withFonts = require('next-fonts');const withPlugins = require('next-compose-plugins');const withTM = require('next-transpile-modules')(['react-native-web','native-base',]);const nextConfig = {};module.exports = withPlugins([withTM,[withFonts, { projectRoot: __dirname }],[withExpo, { projectRoot: __dirname }],],nextConfig);
Copymodule.exports = {presets: ['next/babel'],plugins: [['react-native-web', { commonjs: true }]],};
Copymodule.exports = {presets: ['@expo/next-adapter/babel'],plugins: [['@babel/plugin-proposal-class-properties']],};
Copyimport Document, { Html, Head, Main, NextScript } from 'next/document';import Ionicons from 'react-native-vector-icons/Fonts/Ionicons.ttf';import MaterialIcons from 'react-native-vector-icons/Fonts/MaterialIcons.ttf';import AntDesign from 'react-native-vector-icons/Fonts/AntDesign.ttf';import MaterialCommunityIcons from 'react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf';// Generate required cssconst iconFontStyles = `@font-face {src: url(${Ionicons});font-family: Ionicons;}@font-face {src: url(${MaterialIcons});font-family: MaterialIcons;}@font-face {src: url(${AntDesign});font-family: AntDesign;}@font-face {src: url(${MaterialCommunityIcons});font-family: MaterialCommunityIcons;}`;class MyDocument extends Document {static async getInitialProps(ctx) {const initialProps = await Document.getInitialProps(ctx);return { ...initialProps };}render() {return (<Html><Head><style>{iconFontStyles}</style></Head><body><Main /><NextScript /></body></Html>);}}export default MyDocument;
Copyimport React from 'react';import { getInitialProps } from '@expo/next-adapter/document';import Document, { Html, Head, Main, NextScript } from 'next/document';class CustomDocument extends Document {render() {return (<Html style={{ height: '100%' }}><Head><meta httpEquiv="X-UA-Compatible" content="IE=edge" /></Head><body style={{ height: '100%', overflow: 'hidden' }}><Main /><NextScript /></body></Html>);}}// Import the getInitialProps method and assign it to your component to ensure the react-native-web styles are used.CustomDocument.getInitialProps = getInitialProps;export default CustomDocument;
Copy// Incorrect Way to pass theme tokens to utility props<Box p={4} mx={8} /> ❌
Copy// Correct Way to pass theme tokens to utility props<Box p="4" mx="8" /> ✅
Copy/* correct */<Icon as={Ionicons} name="md-checkmark-circle" />/* incorrect */<Icon as={<Ionicons name="md-checkmark-circle" />} />/* incorrect */<Icon as={<Ionicons />} name="md-checkmark-circle" />
Fetched URL: https://docs.nativebase.io/migration/v3xtov32
Alternative Proxies: