react-bootstrap-table2 icon indicating copy to clipboard operation
react-bootstrap-table2 copied to clipboard

Paginator error in VS2017 with typescript

Open vinhlevinhle opened this issue 8 years ago • 9 comments

Hi, I am using vs2017 react template with typescript. I am just using the basic table works fine but when i included paginator feature I get typescript compilation error so to get around this I declared an index.t.ts in the @type folder. eg: import * as React from "react"; export class paginator extends React.Component<any,any> { } export default paginator;

But VS2017 typescript compiler still wont understand this when i call paginator() function inside BootstrapTable as below:

I suspected my type definition is incorrect for paginator. However, I did the same for BootstrapTable and it worked fine.

I have the latest react 16.1.1

Any help be great.

vinhlevinhle avatar May 24 '18 17:05 vinhlevinhle

when i installed npm for paginator , I notice some warning. But i can't work out if they are related to my issues.

E:\Dev-old\Test NodeJS\typescript_project\testcore2.0\WebApplication1_netcore2.1\WebApplication1_netcore2.1>npm install react-bootstrap-table2-paginator --save npm WARN saveError Problems were encountered npm WARN saveError Please correct and try again. npm WARN saveError extraneous: undefined E:\Dev-old\Test NodeJS\typescript_project\testcore2.0\WebApplication1_netcore2.1\WebApplication1_netcore2.1\node_modules@types\react-bootstrap-table-next npm WARN saveError extraneous: [email protected] E:\Dev-old\Test NodeJS\typescript_project\testcore2.0\WebApplication1_netcore2.1\WebApplication1_netcore2.1\node_modules\react npm WARN saveError extraneous: [email protected] E:\Dev-old\Test NodeJS\typescript_project\testcore2.0\WebApplication1_netcore2.1\WebApplication1_netcore2.1\node_modules\react\node_modules\fbjs npm WARN saveError extraneous: [email protected] E:\Dev-old\Test NodeJS\typescript_project\testcore2.0\WebApplication1_netcore2.1\WebApplication1_netcore2.1\node_modules\react\node_modules\prop-types npm WARN saveError extraneous: [email protected] E:\Dev-old\Test NodeJS\typescript_project\testcore2.0\WebApplication1_netcore2.1\WebApplication1_netcore2.1\node_modules\react-dom npm WARN saveError extraneous: [email protected] E:\Dev-old\Test NodeJS\typescript_project\testcore2.0\WebApplication1_netcore2.1\WebApplication1_netcore2.1\node_modules\react-dom\node_modules\fbjs npm WARN saveError extraneous: [email protected] E:\Dev-old\Test NodeJS\typescript_project\testcore2.0\WebApplication1_netcore2.1\WebApplication1_netcore2.1\node_modules\react-dom\node_modules\prop-types npm WARN saveError peer invalid: react@^15, required by [email protected] npm WARN saveError peer invalid: react@^15, required by [email protected] npm WARN saveError peer invalid: react@^15, required by [email protected] npm WARN saveError peer invalid: react@^0.14.0 || ^15.0.0, required by [email protected] npm WARN saveError peer invalid: react-dom@^0.14.0 || ^15.0.0, required by [email protected] [email protected] E:\Dev-old\Test NodeJS\typescript_project\testcore2.0\WebApplication1_netcore2.1\WebApplication1_netcore2.1 +-- UNMET PEER DEPENDENCY [email protected] invalid `-- [email protected]

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN enoent ENOENT: no such file or directory, open 'E:\Dev-old\Test NodeJS\typescript_project\testcore2.0\WebApplication1_netcore2.1\WebApplication1_netcore2.1\node_modules@types\react-bootstrap-table-next\package.json' npm WARN [email protected] requires a peer of react@^15 but none was installed. npm WARN [email protected] requires a peer of react@^15 but none was installed. npm WARN [email protected] requires a peer of react@^15 but none was installed. npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0 but none was installed. npm WARN [email protected] requires a peer of react-dom@^0.14.0 || ^15.0.0 but none was installed.

vinhlevinhle avatar May 24 '18 17:05 vinhlevinhle

I forgot to include the code

typescript compile error value of type paginator() is not callable

vinhlevinhle avatar May 24 '18 18:05 vinhlevinhle

@vinhlevinhle seems like your there're duplicated React version was installed in your project?!

BTW, the problem still remain?

The paginator is accept an object like: https://github.com/react-bootstrap-table/react-bootstrap-table2/blob/master/packages/react-bootstrap-table2-paginator/index.js#L3-L6

Not a react class, Anyway, I'm not familiar with TS, hope above can help u.

AllenFang avatar May 28 '18 10:05 AllenFang

Hi Allan, Appreciate your prompt response. I still have the same issue. I also noted a few people were raising similar issue about this.

I use MS VS 2017 react redux template. Only when I use pagination that when it is a problem. BootstrapTable next on its own work perfectly.

Cheers, Vinh

On 28 May 2018, at 8:24 pm, Allen [email protected] wrote:

@vinhlevinhle seems like your there're duplicated React version was installed in your project?!

BTW, the problem still remain?

The paginator is accept an object like: https://github.com/react-bootstrap-table/react-bootstrap-table2/blob/master/packages/react-bootstrap-table2-paginator/index.js#L3-L6

Not a react class, Anyway, I'm not familiar with TS, hope above can help u.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

vinhlevinhle avatar May 28 '18 11:05 vinhlevinhle

@vinhlevinhle so if your change the type, the problem still there? As I mentioned above, the paginator accept an object like https://github.com/react-bootstrap-table/react-bootstrap-table2/blob/master/packages/react-bootstrap-table2-paginator/index.js#L3-L6

AllenFang avatar May 28 '18 11:05 AllenFang

BTW, I saw your stackoverflow issue: https://stackoverflow.com/questions/50521213/type-definition-error-for-paginator-with-react-bootstraptable-in-vs2017-typescri

Error: PaginationWrapper.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

I do believe your React is before React@16 or have duplicated react version installed!. Please check it firstly

AllenFang avatar May 28 '18 12:05 AllenFang

Ok I ll look into if I have duplicated react version.

Vinh

On 28 May 2018, at 10:08 pm, Allen [email protected] wrote:

BTW, I saw your stackoverflow issue: https://stackoverflow.com/questions/50521213/type-definition-error-for-paginator-with-react-bootstraptable-in-vs2017-typescri

Error: PaginationWrapper.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

I do believe your React is before React@16 or have duplicated react version installed!. Please check it firstly

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

vinhlevinhle avatar May 28 '18 13:05 vinhlevinhle

@vinhlevinhle thanks, because react-bootstrap-table2 need ^react@16, particular for pagination, so I add peerDependency for react and react-dom, actually, for above error message and first information you shared, all the clue show that your React version is not met.

Do let me know if this problem still remain after checking and please open issue again so that I can observer it. Thank you

AllenFang avatar May 28 '18 13:05 AllenFang

I just sent you a snap shot that my react lib version is above 16.x.x

Ok I will open issue again if I still cannot get it to work.

Cheers, Vinh

On 28 May 2018, at 11:25 pm, Allen [email protected] wrote:

@vinhlevinhle thanks, because react-bootstrap-table2 need ^react@16, particular for pagination, so I add peerDependency for react and react-dom, actually, for above error message and first information you shared, all the clue show that your React version is not met.

Do let me know if this problem still remain after checking and please open issue again so that I can observer it. Thank you

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

paginator-typeerror

vinhlevinhle avatar May 28 '18 14:05 vinhlevinhle