小编Dav*_*tti的帖子

SSL/HTTPS 的服务器发送事件 (SSE) 问题

你好,我正在 React 中开发一个 Web 应用程序,它使用 Nginx 从 Express 服务器接收 SSE 数据。

\n\n

服务器端JS

\n\n
const express = require(\'express\');\nconst bodyParser = require(\'body-parser\');\nconst cors = require(\'cors\');\nconst crypto = require(\'crypto\');\n\nconst app = express();\n\nvar lastClientRes = null;\nfunction eventsHandler(req, res, next) {\n  const headers = {\n    \'Content-Type\': \'text/event-stream\',\n    \'Connection\': \'keep-alive\',\n    \'Cache-Control\': \'no-cache\'\n  };\n  res.writeHead(200, headers);\n\n  const clientId = Date.now();\n  const newClient = {\n    id: clientId,\n    nonce: null,\n    cart: null,\n    res\n  };\n  requests.push(newClient);\n\n\n  const data = `data: ${JSON.stringify({client: clientId})}\\n\\n`;\n  res.write(data);\n\n  req.on(\'close\', () => {\n    console.log(`${clientId} Connection …
Run Code Online (Sandbox Code Playgroud)

nginx node.js express server-sent-events reactjs

4
推荐指数
1
解决办法
7948
查看次数

React Navigation 5 标题重叠

我正在 React Native 中创建一个应用程序,我正在使用React Navigation 5.x并且我已经用我创建的一个替换了默认标头,这是代码的一部分:

应用程序.js

    <NavigationContainer>
      <Drawer.Navigator initialRouteName="Home" drawerContent={SideMenu} drawerStyle={{
    backgroundColor: '#fff',
    width: Dimensions.get('window').width - 120,
  }}>
        <Drawer.Screen name="Home" component={StackNav} />
      </Drawer.Navigator>
    </NavigationContainer>
Run Code Online (Sandbox Code Playgroud)

堆栈导航

    <Stack.Navigator   headerMode="float" screenOptions={{
      cardShadowEnabled: false,
      cardOverlayEnabled:false,
      headerTransparent: true,
      headerBackTitleVisible: false,
      gestureEnabled: true,
      headerTintColor: currentTheme.colors.primary,
      headerTitleStyle: styles.headerTitle,
      gestureDirection:"horizontal",
      headerStyleInterpolator: HeaderStyleInterpolators.forStatic,
      cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
        header: ({ scene, previous, navigation }) => {
        const { options } = scene.descriptor;
        const title =
          options.headerTitle !== undefined
            ? options.headerTitle
            : options.title !== undefined
            ? options.title
            : scene.route.name;

        return …
Run Code Online (Sandbox Code Playgroud)

react-native react-navigation

4
推荐指数
2
解决办法
5097
查看次数