Home > Blockchain >  Jquery Pagination In React - Expected an assignment or function call and instead saw an expression
Jquery Pagination In React - Expected an assignment or function call and instead saw an expression

Time:03-10

I was adding pagination in my react file using Jquery but I'm getting this error below :

enter image description here

And here Is the code of Jquery code below :

enter image description here

Which tells that the error is at the line starting from $('#page-content').text('Page ' page) ' content here';

I've tried to search about it but I still didn't get the solution. Can u pls tell me what is wrong with that line or with my whole code? Thanks in Advance :)

CodePudding user response:

For line 29 try

$('#page-content').text(`Page ${page} Content here`);

Or

$('#page-content').text('Page '   page   ' content here');

The way you have it

$('#page-content').text('Page '   page)   ' content here';

you are concatinating ' content here' to the result of $('#page-content').text('Page ' page) but not assigning that to any new variable hence the expression error.

On another note - mixing jQuery and React is not recommended as jQuery maniuplates the DOM directly, and React uses the virtual DOM and there is no way for the two to communicate with each other. For example, React components will not rerender when jQuery makes changes to the DOM with jQuery.

  • Related