-
Notifications
You must be signed in to change notification settings - Fork 110
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
adding injectTapEventPlugin() break my hot-reload setup #61
Comments
@sulliwane did you solve or figured out about this? |
Just wrap in a try catch. Quick 'hacky' fix. |
I've tried to reproduce this, do you get any other errors in the console output? |
I only received the error while using jspm's hot reloader, not webpack. I don't have the environment that was producing the error on hand, but this is the code that produced it: alreadyInjected = true;
require('react/lib/EventPluginHub').injection.injectEventPluginsByName({
'TapEventPlugin': require('./TapEventPlugin.js')(shouldRejectClick)
}); Hope that helps. Note: I do realise that this is more a problem with my hot-reload setup then with your library |
How I'm doing this with the SystemJS hot reloader: import getHotReloadStore from 'systemjs-hot-reloader-store';
const hotStore = getHotReloadStore('myproject:index'); // store for state over hot reloads
if (!hotStore.tapInjected) {
injectTapEventPlugin();
hotStore.tapInjected = true;
} |
That is definitely a cleaner way of doing it. Can I just point out you wrote hotStore.tabInjected instead of hotStore.tapInjected. Sorry - just my OCD acting up ;) |
@julienvincent I'm a bit confused, any way to use |
@diegoaguilar I have never experienced any issues with webpack hot-reloading and this plugin. What would be helpful in finding the issue is creating a bare, minimal repo that uses the latest webpack, babel (or whatever your transpiler is) and injectTabEventPlugin. |
If said repo still fires the error you are experiencing, then link it here |
@julienvincent Thanks, fixed it. |
hi guys--wondering if there is: A) Consensus on a workaround for this Thanks! cc @guybedford |
import React, {Component} from 'react';
import injectTapEventPlugin from 'react-tap-event-plugin';
class App extends Component {
componentWillMount() {
injectTapEventPlugin();
}
render() {...};
} |
@extonec - that still gives me the same issue. Strange that it works for you. class App extends Component {
componentWillMount() {
// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
injectTapEventPlugin()
}
render() {
return (
<Provider store={store}>
<MuiThemeProvider>
<Router history={browserHistory}>
{routes}
</Router>
</MuiThemeProvider>
</Provider>
)
}
}
const render = () => {ReactDOM.render(<App />, document.getElementById('app'))};
store.subscribe(render);
store.subscribe(() => console.log(store.getState()))
render(); Yields:
|
Let's the story, the place you're calling it causes it to be called multiple times. We moved the injection into a separate module, since this module doesn't change it's never reimported and therefore only executed once. import injectTapEventPlugin from 'react-tap-event-plugin';
// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
// Used by Material-ui
injectTapEventPlugin(); |
Sorry maybe is me, but I've react 15.5.4 and react-tap-event-plugin 2.0.1, and i suffer the same error where i've to call injectTapEventPlugin()? |
@Gabber |
Putting it next to my render method doesn't work for me. Why does this happen in the first place? |
Seems my pr #106 will solve it. I add import injectTapEventPlugin from 'react-tap-event-plugin'
if (!injectTapEventPlugin.isInjected()) {
injectTapEventPlugin()
} This will prevent the error occur. |
@creeperyang PR #106 is open with error "This branch has conflicts that must be resolved" |
@kfern Just long time after I opened my pr. |
After I add this:
Both of my hot reload setup don't "hot reload" anymore:
If I remove it, then my changes on save are hot-reloaded in the browser (without the need to refresh the page).
any ideas?
thanks.
The text was updated successfully, but these errors were encountered: