Comments (7)
hey, @littlepsylo.
Thank you for catching this.
I'm not sure what the implications would be if the user was actually on a mobile device.
However, I think this might be good enough. I'm assuming react would try to re-render the component on the client side when it is done rendering, right?
Are you seeing any weirdness with mobile devices?
Thank you!
from react-flexible-switch.
Yes, it's definitly not a good solution and finally i used a trick... an ugly one :(
For making this work, I'm forcing react to render client side again with your component, and without on the server, but this is not very comfortable and optimized. The problem is when rendering on the server, window
does not exist and this just crash the app in both desktop or touch devices.
from react-flexible-switch.
Let's try and change it to something like:
this.isTouchDevice = window && window['ontouchstart'] !== undefined;
This might be enough to get everything working I think.
from react-flexible-switch.
Ok thanks, i try this tonight.
from react-flexible-switch.
hey, @littlepsylo. Do you still wanna try to work on this?
from react-flexible-switch.
Hi ! Sorry for my late return, too much work...
I have a project that use version 0.3.4, that i have to resume soon, so i could look at it at the same time.
And for information, during a demo of this project, when trying to use a switch with my mouse on a touch screen, only touch working not click. I will re-test that too.
from react-flexible-switch.
Your previous solution still does not work, window isn't defined...
But i've found a working fix by removing
this.isTouchDevice = window['ontouchstart'] !== undefined;
And updating addListener
and removeListener
by replacing
if (this.isTouchDevice) {
with
if (window['ontouchstart'] !== undefined) {
And now it's work with SSR.
This is make sense because these 2 methods are not called during server side rendering but when the component is mounted or unmounted. This only happens on browser, not on server.
from react-flexible-switch.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-flexible-switch.