Here is a npm library which can handle window, document and global object for you: Global.
Then you can safely write:
import window from 'global'
const mySpecialWindowFunction = () => {
return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase());
};
More Related Contents:
- styled components final styles are injected directly in DOM with tag, with style tag injection does performance gets affected?
- The create-react-app imports restriction outside of src directory
- Correct path for img on React.js
- babel-loader jsx SyntaxError: Unexpected token [duplicate]
- How to load image files with webpack file-loader
- ES6 modules implementation, how to load a json file
- How to import image (.svg, .png ) in a React Component
- firebase.auth is not a function
- When should I use brackets with imports
- How to store Configuration file and read it using React
- where is create-react-app webpack config and files?
- Importing CSS files in Isomorphic React Components
- Webpack output is empty object
- Error: How to serialize data from getStaticProps : Next.js
- Webpack breaking change
- Is it possible to use dotenv in a react project?
- “You may need an additional loader to handle the result of these loaders.”
- how to set up an inline svg with webpack
- Electron IPC and nodeIntegration
- Webpack 5 – Uncaught ReferenceError: process is not defined
- Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module ‘babel-preset-react’
- Why is my webpack bundle.js and vendor.bundle.js so incredibly big?
- how can I use top level “await” in typescript next.js
- How can I fix the “BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default" error?
- How to dynamically import SVG and render it inline
- React ‘cannot read property of undefined’ when using map
- How to pass data from a page to another page using react router
- How to use componentWillMount() in React Hooks?
- Service Worker registration error: Unsupported MIME type (‘text/html’)
- Proper way of using React hooks + WebSockets