小编Aye*_*har的帖子

将多个堆栈导航器中常见的所有屏幕放在哪里?- 反应导航 v5

以下是我的应用程序导航器的层次结构

???appNavigator(底部标签导航器)

  • ???提要(堆栈导航器)

    • 后详细信息屏幕
    • 页面详细信息屏幕
    • 配置文件详细信息屏幕
    • ...其他屏幕
  • ???通知(堆栈导航器)

    • 配置文件详细信息屏幕
    • 页面详细信息屏幕
    • 发布详细信息屏幕
    • ...其他屏幕
  • ???个人资料(堆栈导航器)

    • 配置文件详细信息屏幕
    • 页面详细信息屏幕
    • 发布详细信息屏幕
    • ...其他屏幕

现在的问题是我必须复制所有堆栈中通用的屏幕(ProfileDetail、PostDetail 和 PageDetail),以便在堆栈中访问它们。

对于此用例,是否有更好的解决方案。我应该在哪里放置通用屏幕,以便它们在所有子堆栈中可用,并且我不必在任何地方复制它们。

这是我经历的一个开放的 github 问题,但找不到好的解决方案 Isuue

reactjs react-native react-navigation react-navigation-stack react-navigation-v5

13
推荐指数
1
解决办法
1559
查看次数

样式组件如何转发 props?

我使用样式组件已经有一段时间了,但说实话,我从来没有真正理解它是如何工作的。这就是我的问题所在。

所以,我理解样式组件可以根据道具进行调整。我不明白的是道具的转发是如何工作的。

例如,就我而言,我正在使用 React Native。我为输入字段提供了一些默认道具。现在,样式化组件包装器会自动拾取默认高度道具,但如果我显式传递该道具,它不会拾取它,我必须手动从道具中获取它。那是关于什么的?

import React from "react";
import styled from "styled-components/native";

const StyledTextInput = styled.TextInput`
   /* Why do I have to do this for custom heights.
    * Isn't height automatically get forwarded?
    */

  /* if I comment this height style out, It takes defaultProp height but doesn't take custom height
   * I have to uncomment it for the custom height
   */

  height: ${({ height }) => height};

   ...other styles
`;

const TextInput = ({ height }) => { …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native styled-components

5
推荐指数
1
解决办法
4622
查看次数

为什么我得到“parserOptions.project”已设置为 @typescript-eslint/parser 专门用于 .test.ts 文件?

.test.ts过去三天我一直在尝试修复文件的此错误。

我有我tsconfig的如下

{
  "compilerOptions": {
    "target": "es6",                                     /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
    "lib": ["ESNext"],                                   /* Specify a set of bundled library declaration files that describe the target runtime environment. */
   "module": "commonjs",                                /* Specify what module code is generated. */
    "rootDir": "./src",                                  /* Specify the root folder within your source files. */
    "moduleResolution": "node",                          /* Specify how TypeScript looks up a file from a given module specifier. …
Run Code Online (Sandbox Code Playgroud)

node.js typescript eslint

5
推荐指数
1
解决办法
2万
查看次数

React Navigation v5:如何在子屏幕内获取父导航器的路由参数

所以我嵌套了导航器

Main BottomTab.Navigator

  • 配置文件底部选项卡 # 1 (Stack.Navigator)
    • 个人资料视图(屏幕)
    • 追随者(屏幕)
    • 关注(顶部 Tab.Navigator)
      • 页面(屏幕)
      • 组(屏幕)
  • 进料底部标签 #2(堆叠)
  • 其他一些底部选项卡 #3(堆栈)

问题是当我从 Profile View Screen 导航到 Follow Navigator 时,我将一些参数传递给了父 Follow Navigator,并且我希望所有这些参数都在子选项卡屏幕(页面/组)中。

但是子选项卡屏幕的路由没有获取传递给父导航器的参数(以下选项卡导航器)

有没有办法做到这一点?

这是我的代码: 配置文件堆栈

const ProfileStack = () => (
  <Stack.Navigator
    initialRouteName='profileView'
  >
    <Stack.Screen
      name='profileView'
      component={ProfileScreen}
      options={{
        headerMode: 'screen',
        headerShown: false,
      }}
    />

    <Stack.Screen
      name='followers'
      component={FollowersScreen}
      options={{
        headerTitle: 'Followers',
      }}
    />
    <Stack.Screen
      name='following'
      component={FollowingTabs}
      options={{
        headerTitle: 'Following',
      }}
    />
 </Stack.Navigator>

Run Code Online (Sandbox Code Playgroud)

跟随标签

const Tabs = createMaterialTopTabNavigator();
export const FollowingTabs …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-navigation react-navigation-v5

2
推荐指数
1
解决办法
4699
查看次数

切换到新的 git 分支时 -b 和 -B 有区别吗?

这可能是一件很小的事情。我注意到有人在互联网上打字,-B而不是-b在切换到新分支时打字。

git checkout -B new_branch
Run Code Online (Sandbox Code Playgroud)

这意味着什么?我们什么时候使用大写 B。如果-D我们用大写 D 标志强制删除。资本 B 会发生什么?

Force deletion:
git branch -D local_branch
Run Code Online (Sandbox Code Playgroud)

我尝试查看这些很棒的git Flight Rules,但没有找到任何内容。

任何帮助,将不胜感激。

git github gitlab

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