Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer a isInjected function to allow user check if plugin is injected #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

creeperyang
Copy link

When develop react app with webpack-hot-middleware to enable hot reload, react-tap-event-plugin will always print warning message:

Invariant Violation: injectTapEventPlugin(): Can only be called once per application lifecycle.

It is recommended to call injectTapEventPlugin() just before you call ReactDOM.render(). If you are using an external library which calls injectTapEventPlugin() itself, please contact the maintainer as it shouldn't be called in library code and should be injected by the application.
    at invariant (/REPO/node_modules/fbjs/lib/invariant.js:44:15)
    at injectTapEventPlugin (/REPO/node_modules/react-tap-event-plugin/src/injectTapEventPlugin.js:11:5)
    at Object../src/components/Layout/index.js (/REPO/src/components/Layout/index.js:14:1)
    at __webpack_require__ (/REPO/webpack/bootstrap aeb843e7799316fcb8cb:635:1)
    at fn (/REPO/webpack/bootstrap aeb843e7799316fcb8cb:47:1)
    at Object../src/routes/home/index.js (/REPO/build/chunks/home.js:318:77)
    at __webpack_require__ (/REPO/webpack/bootstrap aeb843e7799316fcb8cb:635:1)
    at fn (/REPO/webpack/bootstrap aeb843e7799316fcb8cb:47:1)
    at <anonymous>

It's annoying and will prevent hot reload working correctly.

So, it's great to offser something like:

if (!injectTapEventPlugin.isInjected()) {
  injectTapEventPlugin()
}

@prescottprue
Copy link

+1 would be nice to have

@alexanderwhatley
Copy link

+1 This would be useful for me as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants