gpt4 book ai didi

reactjs - 模块 '' meteor/react-meteor-data '' has no exported member ' withTracker'

转载 作者:搜寻专家 更新时间:2023-10-30 21:36:45 26 4
gpt4 key购买 nike

我正在尝试将我的 Meteor-React 项目迁移到 TypeScript。我有一个 .tsx 文件:

import { withTracker } from 'meteor/react-meteor-data';

class Header extends React.Component<any,any> {
...
}

export default withTracker(() => {
return {
...
};
})(Header);

但我收到了错误,即使网站正确呈现:

Module ''meteor/react-meteor-data'' has no exported member 'withTracker'.

运行版本:

Local package version is up-to-date: babel-compiler@7.0.6
Local package version is up-to-date: babel-runtime@1.2.2
Local package version is up-to-date: barbatus:typescript@0.6.12
Local package version is up-to-date: barbatus:typescript-compiler@0.9.12
Local package version is up-to-date: barbatus:typescript-runtime@1.0.2
Local package version is up-to-date: ecmascript@0.10.6
Local package version is up-to-date: ecmascript-runtime@0.5.0
Local package version is up-to-date: ecmascript-runtime-client@0.6.2
Local package version is up-to-date: ecmascript-runtime-server@0.5.0
Local package version is up-to-date: meteor@1.8.6
Local package version is up-to-date: react-meteor-data@0.2.16

感谢您的帮助。

最佳答案

react-meteor-data 包不包含类型信息。 This repository包含旧 createContainer 的类型,但 repo 尚未使用 withTracker 更新。

我通过在项目中的某处包含一个 .d.ts 文件来解决这个问题,声明如下:

declare module 'meteor/react-meteor-data' {
import * as React from 'react';

type RMDComponentConstructor<P> = React.ComponentClass<P> | React.StatelessComponent<P>

export function withTracker<InP, D, OutP extends (InP & D)>(
options: (props: InP) => D | {getMeteorData: (props: InP) => D, pure?: boolean}):
(reactComponent: RMDComponentConstructor<OutP>) => RMDComponentConstructor<InP>;
}

关于reactjs - 模块 '' meteor/react-meteor-data '' has no exported member ' withTracker',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50086332/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com