meteor / meteor/react-packages

Example of usage meteor/react-meteor-data with `withRouter` in typescript

Open
#368 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
575
Forks
168
Avg merge
4d 3h
Merged PRs (30d)
1

Description

I am using this package with typescript

https://packosphere.com/meteor/react-meteor-data

My code

```
import React from 'react';
// import {withRouter} from 'react-router-dom';
import {withTracker} from 'meteor/react-meteor-data';
import {RouteComponentProps, withRouter} from 'react-router-dom';

interface IProps extends RouteComponentProps {
title: string;
}

class MyComp extends React.Component {
public render(): JSX.Element {
return

{this.props.title}

;
}
}

export default withRouter(
withTracker(() => {
return {title: 'ok'};
})(MyComp)
);
```

Error:

![2022-11-03_19-06](https://user-images.githubusercontent.com/16663028/199758535-15f37e4b-1676-45a5-9830-0ca328543adc.png)

Description

> TS2345: Argument of type 'ComponentClass<unknown, any>' is not assignable to parameter of type 'typeof MyComp & ComponentType<IProps>'.
Type 'ComponentClass<unknown, any>' is not assignable to type 'typeof MyComp & ComponentClass<IProps, any>'.
Type 'ComponentClass<unknown, any>' is not assignable to type 'typeof MyComp'.
Construct signature return types 'Component<unknown, any, any>' and 'MyComp' are incompatible.
The types returned by 'render()' are incompatible between these types.
Type 'ReactNode' is not assignable to type 'Element'.
Type 'undefined' is not assignable to type 'ReactElement<any, any>'.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the TypeScript error at the meteor/react-meteor-data entry point with the shown withRouter and withTracker composition. No repository files or tests are named, so locate the package typings and existing TypeScript coverage before defining the fix. Done means the example composes without TS2345 and its intended prop types remain valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.