Comments (8)
A react-image-lightbox-universal
repo has apparently been made (kind of wish they made a pull request).
So if you're in a hurry, that will get you up and running quickly, but it lacks many of the more recent improvements and fixes I've made. It will at least be a good reference for making this project SSR-compatible.
from react-image-lightbox.
An alternative until this is fixed is to wrap the Lightbox in a class (which is convenient for using it anyway) and only require it in the constructor instead of on top of the file. And only include this new module when the lightbox is open. That might cause performance to be a tiny bit less the first time your load it. But it will make server side rendering possible since the module is never loaded on the server (because no lightboxes are open without user interaction).
https://gist.github.com/tiemevanveen/96829e68f12fd6864ee5be72eaece03e
from react-image-lightbox.
@mikelambert i will look into the latest version and see if i can incorporate it to make it work in universal. and then will send pull request.
from react-image-lightbox.
Ah, I figured this issue was going to pop up eventually. I haven't had the chance to do SSR myself, so I'm not too familiar with the ins and outs of it, but if I had to guess, I'd say the issue originates from one of these parts:
- Using
style-loader
with webpack to append styles to the page. I really like the idea ofstyle-loader
, because you don't have to deal with adding the style files yourself, and it still acts like normal css. However, it becomes a problem in cases like SSR and CSS class precedence, so I'm considering just separating the style files out into a single CSS file, as is being done inreact-virtualized
, which a lot of my build is based off of. - Accessing
window
directly in several places. Again, this is probably a symptom of not having worked with SSR before, but I use it to get theclientWidth
andclientHeight
, and also to attachmouseup
handlers (somouseup
events falling outside the window still get caught). - Browser-specific rendering. I do some stuff like the
getIEVersion()
method you mentioned to make it compatible with IE 9 (which doesn't have 3D CSS transforms or flexbox).
If you could offer any advice/pull requests based on your experience, I would really appreciate it. For the time being, I guess I'll make external CSS files a v4.0 goal.
from react-image-lightbox.
I made the CSS issue at #28
from react-image-lightbox.
@abhirathore2006, any interest in upstreaming your universal changes back to this repo? You're 7 commits ahead with your changes, but 78 commits behind...
I tried to go do it myself (the this.state is very straightforward), but realized I don't understand this lightbox-webpack parts well enough to upstream them myself.
from react-image-lightbox.
@fritz-c i didn't made pull request because changes i made were huge, you can check the log here abhirathore2006@d1305fb
from react-image-lightbox.
Fixed by #54
from react-image-lightbox.
Related Issues (20)
- Click close button behave to be scroll to prev image
- Image cache issue on react image light
- usage of deprecated life cycle methods, getting warnings of the same HOT 4
- Library maintenance and improvements HOT 14
- Centering problem when page has a scrollbar
- Bad overlay..
- How can I put a link on the title just like the demo?
- Is Medium Zoom effect possible
- Doc improvement request for reactModalStyle
- Blinkin when pushing the button supposed to trigger the state set in onMoveNextRequest
- Animation Duration Is Blocking Prev/Next Button Clicks
- Missing "loader" in TypeScript Types
- Loading icon gets stuck in React 18 dev mode HOT 17
- Need custom component PR Merged
- Uncaught ReferenceError: global is not defined HOT 4
- Need thumbnail images on bottom of the screen
- Does it work with React 18? HOT 3
- Image not loading on launch when React.StrictMode is enabled. HOT 6
- Info: Proper typescript component React 18.2.0 and Gatsby With tailwind
- React 18 not supported. HOT 4
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-image-lightbox.