如何在打字稿/反应中创建基本的观察者类?

时间:2019-12-14 18:14:58

标签: reactjs typescript mobx mobx-react

我的react应用有一个共同的模式,其中我有许多观察相同模型的组件。每个组件的代码如下:

this.state.cards.push

我想通过声明这样的基类来简化此过程:

export interface IAppModel {
    someLocation: { x: number, y: number } ;
    doSomething: () => void;
};


@inject("appModel")
@observer
export default class MyComponent
  extends React.Component<{appModel?: IAppModel}> { ... }

这给了我一个运行时错误:类扩展了值#不是构造函数或null

不确定是否/如何工作。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我认为您的问题来自if __name__ == '__main__': p = Pool(1) // in this example, all of the code is indented, which will allow it all to work. url = 'http://httpbin.org/post' cookies = {'PHPSESSID': '2a55b01f46b3c7e5764b70666ac81cae'} headers = {"user-agent":"undefined"} data=( ('o_id', (None, '3732')), ('p_owner', (None, '3732')), ('p_name', (None, '1')), ('p_desc', (None, 'null')), ('save', (None, '')), ) def make_request(id): requests.post(url, cookies=cookies, verify=False, headers=headers, files=data) print(p.map(make_request, range(3000, 0, -1))) 请分享