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

[Bug] umi + mobx decorator don't work #9396

Closed
sorrycc opened this issue Sep 21, 2022 · 1 comment
Closed

[Bug] umi + mobx decorator don't work #9396

sorrycc opened this issue Sep 21, 2022 · 1 comment

Comments

@sorrycc
Copy link
Member

sorrycc commented Sep 21, 2022

What happens?

Mini Showcase Repository(REQUIRED)

Please provide a minimal reproduction then upload to your GitHub. 请提供 最小重现,并上传到你的 GitHub 仓库

How To Reproduce

Steps to reproduce the behavior: 1. 2.

Expected behavior 1. 2.

$ umi g page index
$ vi pages/index.tsx

加入以下内容,

import { makeObservable, observable } from 'mobx';
class A {
  @observable
  loading = '1';
  constructor() {
    makeObservable(this);
  }
}
class B extends A {
  loading = '2';
}
const b = new B();
console.log(b);

启动 umi dev,

$ umi dev

报错,

image

Context

  • Umi Version:
  • Node Version:
  • Platform:
@sorrycc
Copy link
Member Author

sorrycc commented Sep 22, 2022

解法:

新增 plugin.ts,内容如下,

export default (api: any) => {
  api.modifyBabelPresetOpts((memo) => {
    memo.presetEnv.loose = true;
    return memo;
  })
}

@sorrycc sorrycc closed this as completed Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant