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

Taro3.6.30 react-native上 使用react-redux的页面无法触发componentDidShow #16858

Closed
Slngle opened this issue Nov 13, 2024 · 2 comments
Closed

Comments

@Slngle
Copy link

Slngle commented Nov 13, 2024

相关平台

React Native

使用框架: React

复现步骤

import { Component } from 'react'

import { View } from '@tarojs/components'

import { connect } from 'react-redux'

@connect(({ userInfo }) => ({

realName: userInfo.realName,

}))

export default class MyPage extends Component {

componentDidMount() {

console.log('componentDidMount')

}

componentDidShow() {

console.log('componentDidShow')

}

render() {

const { realName } = this.props

return <View className="MyPage">{realName}</View>

}
}

期望结果

控制台打出 componentDidMount componentDidShow

实际结果

只打出 componentDidMount

环境信息

👽 Taro v3.6.30


  Taro CLI 3.6.30 environment info:
    System:
      OS: macOS 14.4.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.20.3 - ~/.nvm/versions/node/v18.20.3/bin/node
      Yarn: 1.22.22 - ~/.nvm/versions/node/v18.20.3/bin/yarn
      npm: 10.7.0 - ~/.nvm/versions/node/v18.20.3/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.30 => 3.6.30 
      @tarojs/components: 3.6.30 => 3.6.30 
      @tarojs/helper: 3.6.30 => 3.6.30 
      @tarojs/mini-runner: 3.6.30 => 3.6.30 
      @tarojs/plugin-framework-react: 3.6.30 => 3.6.30 
      @tarojs/plugin-platform-alipay: 3.6.30 => 3.6.30 
      @tarojs/plugin-platform-h5: 3.6.30 => 3.6.30 
      @tarojs/plugin-platform-jd: 3.6.30 => 3.6.30 
      @tarojs/plugin-platform-qq: 3.6.30 => 3.6.30 
      @tarojs/plugin-platform-swan: 3.6.30 => 3.6.30 
      @tarojs/plugin-platform-tt: 3.6.30 => 3.6.30 
      @tarojs/plugin-platform-weapp: 3.6.30 => 3.6.30 
      @tarojs/react: 3.6.30 => 3.6.30 
      @tarojs/rn-runner: 3.6.30 => 3.6.30 
      @tarojs/rn-supporter: 3.6.30 => 3.6.30 
      @tarojs/runtime: 3.6.30 => 3.6.30 
      @tarojs/runtime-rn: 3.6.30 => 3.6.30 
      @tarojs/shared: 3.6.30 => 3.6.30 
      @tarojs/taro: 3.6.30 => 3.6.30 
      @tarojs/taro-loader: 3.6.30 => 3.6.30 
      @tarojs/taro-rn: 3.6.30 => 3.6.30 
      @tarojs/webpack5-runner: 3.6.30 => 3.6.30 
      babel-preset-taro: 3.6.30 => 3.6.30 
      eslint-config-taro: 3.6.30 => 3.6.30 
      expo: ~47.0.3 => 47.0.14 
      react: ^18.1.0 => 18.3.1 
      react-native: ^0.70.1 => 0.70.15 

补充信息

猜测是高阶产生的问题被react-redux重写。但是里面taro本身react-native实现componentDIdShow可能也用的是高阶

@Slngle Slngle changed the title 使用react-redux的页面无法触发componentDidShow Taro3.6.30 react-native上 使用react-redux的页面无法触发componentDidShow Nov 15, 2024
@Slngle
Copy link
Author

Slngle commented Nov 15, 2024

已解决
@connect(({ userInfo }) => ({

realName: userInfo.realName,

}),null,null,{ forwardRef:true })

@Slngle Slngle closed this as completed Nov 15, 2024
@Slngle
Copy link
Author

Slngle commented Nov 15, 2024

需要判断下环境 不然小程序的didShow出不来了
@connect(({ userInfo }) => ({

realName: userInfo.realName,

}),null,null,{ forwardRef:process.env.TARO_ENV })

This was referenced Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant