React native 导入web组件时反应本机错误
这里我特别告诉react native,当我在web上时,只显示React native 导入web组件时反应本机错误,react-native,styled-components,react-native-web,React Native,Styled Components,React Native Web,这里我特别告诉react native,当我在web上时,只显示GlobalStyle组件(使用样式化组件创建): export default function App() { return ( <Provider store={store}> <ThemeProvider theme={theme}> {Platform.OS === 'web' && <GlobalStyle />}
GlobalStyle
组件(使用样式化组件创建):
export default function App() {
return (
<Provider store={store}>
<ThemeProvider theme={theme}>
{Platform.OS === 'web' && <GlobalStyle />}
<Navigation /> {/* other top-level stuff */}
</ThemeProvider>
</Provider>
);
}
导出默认函数App(){
返回(
{Platform.OS==='web'&&}
{/*其他顶级内容*/}
);
}
然而,我仍然得到一个错误,说:“createGlobalStyle不是一个函数”。如果我从未在移动设备上显示此组件,为什么会发生这种情况?您应该在电子阅读器中使用Navigator
import { createGlobalStyle, ThemeProvider } from 'styled-components'
const GlobalStyle = createGlobalStyle`
body {
color: ${props => (props.whiteColor ? 'white' : 'black')};
font-family: ${props => props.theme.fontFamily};
}
`
// later in your app
<ThemeProvider theme={{ fontFamily: 'Helvetica Neue' }}>
<React.Fragment>
<Navigation /> {/* example of other top-level stuff */}
<GlobalStyle whiteColor />
</React.Fragment>
</ThemeProvider>
从“样式化组件”导入{createGlobalStyle,ThemeProvider}
const GlobalStyle=createGlobalStyle`
身体{
颜色:${props=>(props.whiteColor?'white':'black');
字体系列:${props=>props.theme.fontFamily};
}
`
//稍后在你的应用程序中
{/*其他顶级内容的示例*/}
此处的详细信息您应该在浏览器中使用Navigator
import { createGlobalStyle, ThemeProvider } from 'styled-components'
const GlobalStyle = createGlobalStyle`
body {
color: ${props => (props.whiteColor ? 'white' : 'black')};
font-family: ${props => props.theme.fontFamily};
}
`
// later in your app
<ThemeProvider theme={{ fontFamily: 'Helvetica Neue' }}>
<React.Fragment>
<Navigation /> {/* example of other top-level stuff */}
<GlobalStyle whiteColor />
</React.Fragment>
</ThemeProvider>
从“样式化组件”导入{createGlobalStyle,ThemeProvider}
const GlobalStyle=createGlobalStyle`
身体{
颜色:${props=>(props.whiteColor?'white':'black');
字体系列:${props=>props.theme.fontFamily};
}
`
//稍后在你的应用程序中
{/*其他顶级内容的示例*/}
此处的详细信息抱歉,但这没有帮助。错误是same@PetroIvanenko至少有人想帮你对不起,但这没用。错误是same@PetroIvanenko至少有人想帮你