0

Get the same problem developing my react app. So I have import JQuery using such a command

npm install jquery

Late I download a js min file from the site,

https://redopop.com/loupe/

You can find it at the top. It named jquery.loupe.min.js. So I copied it, and create my own js file in the src folder.

In my header i include all thees files:

import $ from 'jquery';
import './jquery.loupe.min.js'

And in my function, i try to call loop:

  if (this.props.activeItem === "Loop") {
    $('graph').loupe();
    //window.$ = window.jQuery = require('jquery')
    //window.$('graph').loupe();
  }

I think that the second and third lines should work, but it gets the same result. No errors, but nothing. My console.log of window$

     content.js?5f7c:406 ƒ ( selector, context ) {


    // The jQuery object is actually just the init constructor 'enhanced'
    // Need init if jQuery is called (just allow error to be thrown if not included)
    return new jQuery…

So in my render method, I have a canvas that I want to connect with loop:

  <div className="canvas">
    <canvas
      id="graph"
      className="canvas-actual"
      width="800px"
      height="480px"
      ref={this.canvasRef}
      onMouseDown={this.handleMouseDown}
      onMouseMove={this.handleMouseMove}
      onMouseUp={this.handleMouseUp}
    >
    </canvas>

Nothing happed. No errors, or warnings. I have no ideas that matter. Thanks. Code (need python2)

https://github.com/andr1312e/React-recognize

  • if you heed code, ask me –  Dec 20 '20 at 08:38
  • 1
    Dont query the dom use React API with ref. As aside note, you really shouldn't use jquery when you have React. – Dennis Vash Dec 20 '20 at 08:38
  • 1
    I do, it get me an error Uncaught TypeError: Cannot define property jQuery351064704862672539812, object is not extensible –  Dec 20 '20 at 08:49
  • Using jQuery in react is really not recommended, if you want a loupe effect in react, you can refer to this [answer](https://stackoverflow.com/questions/23971717/magnifying-glass-that-follows-cursor-for-canvas) – Shujath Dec 20 '20 at 09:02

1 Answers1

1

Hi Andrew if you use as react.js me suggest for you library react-image-magnifiers

if use react rty use this

react-image-magnifiers: A collection of responsive, image magnifying React components for mouse and touch.

view in npm : https://www.npmjs.com/package/react-image-magnifiers

react-image-magnifiers DEMO: https://adamrisberg.github.io/react-image-magnifiers/

github: https://github.com/AdamRisberg/react-image-magnifiers

Mahdi Sheibak
  • 620
  • 1
  • 4
  • 13