mousetrap
mousetrap copied to clipboard
bindGlobal is not a function
I installed Mousetrap through npm and used it in my react code as follows:
import * as Mousetrap from 'mousetrap';
.
.
.
componentDidMount () { Mousetrap.bindGlobal('enter', this.submitSearch);
However, this returns the following issue:
Uncaught TypeError: mousetrap__WEBPACK_IMPORTED_MODULE_13__.bindGlobal is not a function
Is there a way around this?
You need to use mousetrap-global-bind
since it is a plugin.
Since the bindGlobal
code is included in the normal NPM download, shouldn't there be a way to do it without going to the other NPM package?
@browner12 You can import it, like this:
import Mousetrap from 'mousetrap';
import 'mousetrap/plugins/global-bind/mousetrap-global-bind';
@TurbulentCupcake Please close this issue as completed.