Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RN]navigation.setOptions 路由配置信息,多次跳转之后,参数污染全局winScreenOptions问题 #12743

Closed
jsonchou opened this issue Oct 31, 2022 · 3 comments · Fixed by #12753 or #12895
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x

Comments

@jsonchou
Copy link

jsonchou commented Oct 31, 2022

相关平台

React Native

使用框架: React

复现步骤

 const navBarParams = Object.assign(winScreenOptions, {
        title: headerTitle,
        headerShown: showHeader,
        headerTintColor: color
      }, screenOptions)
      // 页面的config
      if (pageConfig) {
        navigation.setOptions(navBarParams)
      }

=> /@tarojs/router-rn/src/provider.ts
=> handleConfig()

修改为如下,即正常:

      const navBarParams = Object.assign({},{...winScreenOptions}, {
        title: headerTitle,
        headerShown: showHeader,
        headerTintColor: color
      }, screenOptions)
      // 页面的config
      if (pageConfig) {
        navigation.setOptions(navBarParams)
      }

期望结果

每个子页面继承自全局rnConfig信息,且保持子页面独立rnConfig配置。
不要让后续的rnConfig,污染全局以及其他子页面。

实际结果

[RN]navigation.setOptions 路由配置信息,多次跳转之后,参数污染全局winScreenOptions,导致其他子页面表现怪异。

环境信息

  Taro CLI 3.5.5 environment info:
    System:
      OS: macOS 12.5.1
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 16.17.0 - /usr/local/bin/node
      Yarn: 1.22.19 - ~/.yarn/bin/yarn
      npm: 8.15.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 3.5.5 => 3.5.5 
      @tarojs/helper: 3.5.5 => 3.5.5 
      @tarojs/plugin-framework-react: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-alipay: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-jd: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-qq: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-swan: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-tt: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-weapp: 3.5.5 => 3.5.5 
      @tarojs/react: 3.5.5 => 3.5.5 
      @tarojs/rn-runner: 3.5.5 => 3.5.5 
      @tarojs/rn-style-transformer: ^3.5.7 => 3.5.7 
      @tarojs/router: 3.5.5 => 3.5.5 
      @tarojs/runtime: 3.5.5 => 3.5.5 
      @tarojs/shared: 3.5.5 => 3.5.5 
      @tarojs/taro: 3.5.5 => 3.5.5 
      @tarojs/taro-h5: 3.5.5 => 3.5.5 
      @tarojs/taro-rn: 3.5.7 => 3.5.7 
      @tarojs/webpack5-runner: 3.5.5 => 3.5.5 
      babel-plugin-transform-react-jsx-to-rn-stylesheet: ^3.5.7 => 3.5.7 
      babel-preset-taro: 3.5.5 => 3.5.5 
      expo: ~46.0.1 => 46.0.16 
      react: ^18.2.0 => 18.2.0 
      react-native: 0.70.4 => 0.70.4 
    npmGlobalPackages:
      typescript: 4.8.2
@taro-bot2 taro-bot2 bot added F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x labels Oct 31, 2022
@zhiqingchen
Copy link
Member

有修改方法,建议直接pr

@zhiqingchen
Copy link
Member

      const navBarParams = Object.assign({...winScreenOptions}, {
        title: headerTitle,
        headerShown: showHeader,
        headerTintColor: color
      }, screenOptions)
      // 页面的config
      if (pageConfig) {
        navigation.setOptions(navBarParams)
      }

这样就行了吧

@jsonchou
Copy link
Author

jsonchou commented Nov 1, 2022

@zhiqingchen 是的,本地测试也OK了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants