Comments (4)
Found this: webpack/webpack#6525. Thanks again for digging into this!
from react-infinite-scroll-component.
@mrchief I looked at this issue long and deep. I'm using window
only in and after componentDidMount
. This is safe for SSR as componentDidMount
gets called on the client and not on the server.
To test this out, I took a React SSR boilerplate and added InfiniteScroll component in the shared bundle. And it worked without any errors. first commit
Next, I added your dropdown component and it failed saying window
is not defined. At this point I forked your repo, and changed the webpack mode to development so that Dropdown's code isn't minified to debug the issue. (I copy pasted the built files into this repo to access the Dropdown code)
Please see that the error was reported on line number 10, which is output of the IIFE.
I suspect this is because of the way Webpack 4 is generating the UMD definition. I then lowered the Webpack to 2.3.4 which I'm using at work, and built the Dropdown component and it worked fine.
So I'm guessing Webpack 4 is what's causing an issue, and not the infinite scroll component.
I made three commits to this https://github.com/ankeetmaini/infinite-scroll-ssr for you to see the steps.
Let me know if I can help more, and sorry for not getting to it earlier.
from react-infinite-scroll-component.
Webpack 2 generates the IIFE like this - it uses this
instead of window
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"));
else if(typeof define === 'function' && define.amd)
define("ReactDropdownTreeSelect", ["react"], factory);
else if(typeof exports === 'object')
exports["ReactDropdownTreeSelect"] = factory(require("react"));
else
root["ReactDropdownTreeSelect"] = factory(root["React"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_0__) {
return /******/ (function(modules) { // webpackBootstrap
Webpack 4 produces this
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"));
else if(typeof define === 'function' && define.amd)
define("ReactDropdownTreeSelect", ["react"], factory);
else if(typeof exports === 'object')
exports["ReactDropdownTreeSelect"] = factory(require("react"));
else
root["ReactDropdownTreeSelect"] = factory(root["React"]);
})(window, function(__WEBPACK_EXTERNAL_MODULE_react__) {
return /******/ (function(modules) { // webpackBootstrap
from react-infinite-scroll-component.
@ankeetmaini Thanks for this deep dive. Let me take a detailed look and get back to you. This is very helpful! 👍
from react-infinite-scroll-component.
Related Issues (20)
- Block is appearing during scroll HOT 1
- Number 0 appears when finish loading message appears HOT 1
- `scrollableTarget` throws error `Type 'HTMLElement' is not assignable to type 'ReactNode'` in React 18 HOT 3
- Inverse does not work if you do not set a specific height
- Not calling next function on long screens HOT 13
- can not working in shadowDOM
- react-infinite-scroll-component is no longer maintained HOT 3
- The component is not working after a certain amount of items in the list
- Don't loading new content, if initial content height <= screen height HOT 5
- Please modify the npm docs and mention that for the dataLength prop we need to pass the actual length of the data that we are currently rendering.
- TypeError on latest Next.js HOT 4
- Bidirectional Infinite Scroll HOT 2
- Wrong calculation in isElementAtTop method causing percentage scrollThreshold to fail in inverse mode HOT 1
- Invalid Hook call on SetProgress -> 100%
- is this library supported horizontal scroll?
- 【IMPORT FOR EVERYONE】HOW TO FIX:Don't load new items when content height <= screen height HOT 2
- Possibility to pass throttle time as props
- How can I change the scrollY when the InfiniteScroll has rendered HOT 2
- next function doesn't called HOT 3
- Question: focus on the infinityScroll component on the page load
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-infinite-scroll-component.