This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"dependencies": { | |
- "@hot-loader/react-dom": "^17.0.1", | |
- "react": "^17.0.2", | |
- "react-dom": "^17.0.2", | |
+ "react": "^18.2.0", | |
+ "react-dom": "^18.2.0", | |
- "react-redux": "^7.2.4", | |
+ "react-redux": "^8.0.5", | |
- "redux-thunk": "^2.3.0", | |
+ "redux-thunk": "^2.4.2", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TypeError: Cannot read property 'useMemo' of null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TypeError: Cannot read property 'useState' of null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install React 18 in the workspace | |
yarn add react@^18.2.0 react-dom@^18.2.0 -W | |
# Install react 18 type definitions in the workspace | |
yarn add -D @types/react@^18.0.24 @types/react-dom@^18.0.8 -W |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { flushSync } from 'react-dom'; | |
flushSync(() => { | |
currentEl.focus(); | |
setFocused(false); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render, screen } from '@testing-library/react'; | |
import userEvent from '@testing-library/user-event' | |
import { Account } from './Account'; | |
import { ErrorBoundary } from './ErrorBoundary'; | |
describe('Account', () => { | |
it('renders a fallback when an account error is thrown', async () => { | |
const fallback = jest.fn(() => ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function ignoreReact18DOMrenderWarning() { | |
const originalError = console.error; | |
beforeAll(() => { | |
console.error = (...args) => { | |
if (/Warning: ReactDOM.render is no longer supported in React 18./.test(args[0])) { | |
return; | |
} | |
originalError.call(console, ...args); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render } from '@testing-library/react'; | |
import AutoRedirect from './AutoRedirect'; | |
import { mockWindowLocation } from './testUtils'; | |
describe('Navigation', () => { | |
mockWindowLocation(); | |
it('navigates to seatgeek', () => { | |
render(<AutoRedirect />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Jest 26 with latest JSDOM prevents location from being proxied | |
// Instead we can redefine location on window, and then restore. | |
export function mockWindowLocation( | |
mockLocation: Partial<Location> = { | |
href: '', | |
assign: jest.fn(), | |
reload: jest.fn(), | |
} | |
) { | |
const savedLocation = window.location; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getGlobalThis() { | |
return global || globalThis || self || window; | |
} | |
export function disableReactActEnv() { | |
let prev: boolean; | |
beforeEach(() => { | |
prev = getGlobalThis().IS_REACT_ACT_ENVIRONMENT; | |
getGlobalThis().IS_REACT_ACT_ENVIRONMENT = false; | |
}); |