Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 导入web组件时反应本机错误_React Native_Styled Components_React Native Web - Fatal编程技术网

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 />}

这里我特别告诉react native,当我在web上时,只显示
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至少有人想帮你