mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.97k stars 32.28k forks source link

onTouchTap doesn't seem to work with WebPack and ReactJS 14.0x #2291

Closed JasonWeise closed 8 years ago

JasonWeise commented 8 years ago

onTouchTap doesn't seem to work with WebPack. For example with IconMenu I cannot get the menu to open when using WebPack and it appears to be because react-tap-event-plugin is not being initialised. I have included react-tap-event-plugin in node_modules and there are no console errors in browser, just doesn't seem to work at all. The IconMenu itself renders ok and graphically reacts to the click in browser but no MenuItems show at all :(

I am using ReactJS 14.0 with WebPack and none of the components seem to respond if using onTouchTap, I have had to use onClick, but with IconMenu I can't seem to do this... HELP!

Thanks in advance guys :)

If none of that made sense, just let me know and I will try to clarify.

TomJannes commented 8 years ago

Just to be sure... did you call injectTapEventPlugin(); ?

oliviertassinari commented 8 years ago

@TomJannes Thanks

JasonWeiseUnreal commented 8 years ago

Not sure why this was closed? Yes I am calling injectTapEventPlugin(); and it doesn't work.

It doesn't work on the simplest of components.

TomJannes commented 8 years ago

Can you post your code? Is it on github somewhere?

dbismut commented 8 years ago

Hey - I stumbled upon the same issue, and it seems this might happen when loading React as a webpack external, as this issue might suggest. In my case, I'm using the webpack Meteor project bootstrap which loads React externally from a meteor package.

My solution was to add another Meteor package, coniel:react-tap-event-plugin and add it as a webpack external. Then calling injectTapEventPlugin() from my app patches the right React version (and not the one loaded as a dependency by other packages in node_modules).

JasonWeise commented 8 years ago

@dbismut .... great find! that fixed it for me as well.... I was ripping my hair out and started modifying to just use onClick... thanks so much for the tip!