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

使用mobx-react inject装饰的类组件,无法被继承 #8441

Open
ilp64 opened this issue Jan 4, 2021 · 0 comments
Open

使用mobx-react inject装饰的类组件,无法被继承 #8441

ilp64 opened this issue Jan 4, 2021 · 0 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@ilp64
Copy link

ilp64 commented Jan 4, 2021

相关平台

微信小程序

复现仓库

https://github.com/ilp64/taro_mobx_reproduce
小程序基础库: 2.14.1
使用框架: React

复现步骤

1. 使用mobx-react inject装饰类组件

import React, { Component } from 'react';
import Taro from '@tarojs/taro';
import { observer, inject } from 'mobx-react';

@inject('store')
@observer
export class LoginGuard extends Component {
    ......
}

2. 在其他页面组件中继承这个类

......
import { LoginGuard } from '../../guards/login.guard';

console.log('这里不是一个函数或者类了', LoginGuard);

class Index extends LoginGuard {
  render () {
    return (
      <View className='index'>🐞🐞🐞</View>
    );
  }
}

export default Index;

3. 第2步编译能通过,但是在微信开发者工具里面会报运行时错误

VM338:1 TypeError: Super expression must either be null or a function
......

期望结果

希望被inject装饰后也能够被继承

实际结果

我在taro 2的版本里面使用这种写法是没问题的,现在升级到3的时候碰到了这个问题。

环境信息

👽 Taro v3.0.21


  Taro CLI 3.0.21 environment info:
    System:
      OS: macOS 10.14.6
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 14.15.1 - ~/.nvm/versions/node/v14.15.1/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 6.14.8 - ~/.nvm/versions/node/v14.15.1/bin/npm
    npmPackages:
      @tarojs/components: 3.0.21 => 3.0.21 
      @tarojs/mini-runner: 3.0.21 => 3.0.21 
      @tarojs/react: 3.0.21 => 3.0.21 
      @tarojs/runtime: 3.0.21 => 3.0.21 
      @tarojs/taro: 3.0.21 => 3.0.21 
      @tarojs/webpack-runner: 3.0.21 => 3.0.21 
      babel-preset-taro: 3.0.21 => 3.0.21 
      eslint-config-taro: 3.0.21 => 3.0.21 
      react: ^16.10.0 => 16.14.0 


@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

1 participant