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

redux connect + weapp + 函数组件: Component is not found in path #4424

Closed
ionush opened this issue Sep 8, 2019 · 3 comments
Closed
Labels
question Further information is requested

Comments

@ionush
Copy link

ionush commented Sep 8, 2019

问题描述
用connect和函数组件作为page遇到这个报错:

微信开发者工具
image

terminal
image

h5 没有问题。是不是weapp不支持hooks?

复现步骤

const Home = connect(
  ({ homePage, global: { i18n } }) => ({
    homePage,
    i18n,
  }),
  dispatch => ({
    add() {
      dispatch(add())
    },
    dec() {
      dispatch(minus())
    },
    changeLangRequest({ lang }) {
      dispatch(changeLangRequest({ lang }))
    },
  })
)(_Home)

export default Home

const _Home = () => (<View><Text>hello</Text></View>)

期望行为
[这里请用简洁清晰的语言描述你期望的行为]

报错信息

Taro CLI 1.3.12 environment info:
System:
OS: macOS 10.14.6
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.0 - /usr/local/bin/node
npm: 6.9.0 - /usr/local/bin/npm
npmPackages:
@tarojs/async-await: 1.3.14 => 1.3.14
@tarojs/components: 1.3.14 => 1.3.14
@tarojs/plugin-babel: 1.3.14 => 1.3.14
@tarojs/plugin-csso: 1.3.14 => 1.3.14
@tarojs/plugin-sass: 1.3.14 => 1.3.14
@tarojs/plugin-uglifyjs: 1.3.14 => 1.3.14
@tarojs/redux: 1.3.14 => 1.3.14
@tarojs/redux-h5: 1.3.14 => 1.3.14
@tarojs/router: 1.3.14 => 1.3.14
@tarojs/taro: 1.3.14 => 1.3.14
@tarojs/taro-alipay: 1.3.14 => 1.3.14
@tarojs/taro-h5: 1.3.14 => 1.3.14
@tarojs/taro-swan: 1.3.14 => 1.3.14
@tarojs/taro-tt: 1.3.14 => 1.3.14
@tarojs/taro-weapp: 1.3.14 => 1.3.14
@tarojs/webpack-runner: 1.3.14 => 1.3.14
eslint-config-taro: 1.3.14 => 1.3.14
eslint-plugin-taro: 1.3.14 => 1.3.14
nerv-devtools: ^1.4.4 => 1.4.4
nervjs: ^1.4.4 => 1.4.4
react: ^16.9.0 => 16.9.0
stylelint-config-taro-rn: 1.3.14 => 1.3.14
stylelint-taro-rn: 1.3.14 => 1.3.14

@taro-bot
Copy link

taro-bot bot commented Sep 8, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@ionush ionush changed the title weapp: Component is not found in path redux connect + weapp + 函数组件: Component is not found in path Sep 8, 2019
@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 10, 2019

@ionush

函数式组件以大写字母开头,编译时才会找出它进行编译,你写了 _Index 所以编译时没有处理,这里我们考虑加些错误提示吧。

const Home = () => (<View><Text>hello</Text></View>)

const _Home = connect(
  ({ homePage, global: { i18n } }) => ({
    homePage,
    i18n,
  }),
  dispatch => ({
    add() {
      dispatch(add())
    },
    dec() {
      dispatch(minus())
    },
    changeLangRequest({ lang }) {
      dispatch(changeLangRequest({ lang }))
    },
  })
)(Home)

export default _Home

@Chen-jj Chen-jj added answered question Further information is requested labels Sep 10, 2019
@taro-bot
Copy link

taro-bot bot commented Sep 10, 2019

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants