Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
108
rated 0 times [  112] [ 4]  / answers: 1 / hits: 24714  / 7 Years ago, wed, october 25, 2017, 12:00:00

We are facing the issue




Reference Error: self is not defined'




while trying to use React-data-grid. The issue is on the server side while trying to build the nodejs application using webpack. We are facing issue in the generated bundle file in the following lines



isOldIE = memoize(function() {          return /msie
[6-9]b/.test(self.navigator.userAgent.toLowerCase()); }),


Could you let us know how can we fix this. It looks like the react data grid package has issues with the server side rendering.


More From » node.js

 Answers
4

self is likely referring to window which is not available on the server side...it's only available in a browser context. The navigator reference makes this especially apparent. This code is trying to test the user agent for Internet Explorer verison.



self.navigator.userAgent.toLowerCase()


As Jordan pointed out, there is an open issue #361 regarding isomorphic rendering.



If possible, try to avoid executing that code when on the server-side. Otherwise, you'll have to wait for a patch in react-data-grid.


[#56114] Monday, October 23, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jonrened

Total Points: 627
Total Questions: 114
Total Answers: 99

Location: Zimbabwe
Member since Thu, Jul 21, 2022
2 Years ago
;