Skip to content

Uncaught TypeError: Cannot set properties of undefined (setting 'capture') by using React/Electron environment #708

Open
@CxrlosKenobi

Description

@CxrlosKenobi

The general context that I developed a bot that automate the mouse and clicks of the desktop, by using React and Electron for build the App.

BUT, I've been stuck with the next error in Console:

Uncaught TypeError: Cannot set properties of undefined (setting 'capture')
    at Object../node_modules/robotjs/index.js (index.js:23:1)
    at Object.options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:61:1)
    at Module../src/bot/index.js (index.js:1:1)
    at Module.options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:61:1)
    at Module../src/components/Checkboxs.js (index.js:21:1)
    at Module.options.factory (react refresh:6:1)

I used the same sin/cosine example from docs in a js file, then importing the functions into a React component with: import { drawSine } from '../bot/index';
Where my expected behavior for the Electron app is, to use the sin example applied to the component such that when a button is triggered, the function should be executed and the mouse moved by the imported RobotJS script. As in this reference:

import { drawSine } from '../bot/index';

function Checkbox(){ 
  function handleSubmit() {
    drawSine();
  }

  return (
    <button onClick={handleSubmit}>
      Start
    </button>
  );
};

Even tho I rebuilt my project using the Electron docs/wiki provided by RobotJS; Me and my code still stuck by that bug
Uncaught TypeError.

Would someone leave a message of help/hope for this stressed dev?

Environment

  • RobotJS version: 0.6.0
  • Node.js version: v16.13.2
  • npm version: 8.5.1
  • Operating System: Ubuntu 20.04.4 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions