diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json new file mode 100644 index 00000000..02e42543 --- /dev/null +++ b/cypress/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} diff --git a/demo/src/bigList/index.js b/demo/src/bigList/index.js index 86a4642b..c671d83e 100644 --- a/demo/src/bigList/index.js +++ b/demo/src/bigList/index.js @@ -8,7 +8,7 @@ export default { whyDidYouRender(React); class BigListPureComponent extends React.PureComponent { - static whyDidYouRender = { customName: 'BigList' } + static whyDidYouRender = { customName: 'BigList' }; render() { return (
@@ -25,7 +25,7 @@ export default { // Notice, that unlike the huge list, we don't track Main's re-renders because we don't care about it's re-renders. class Main extends React.Component { - state = { count: 0 } + state = { count: 0 }; render() { return (
diff --git a/demo/src/bothChanges/index.js b/demo/src/bothChanges/index.js index 7be6d098..5cec9e80 100644 --- a/demo/src/bothChanges/index.js +++ b/demo/src/bothChanges/index.js @@ -11,11 +11,11 @@ export default { whyDidYouRender(React); class ClassDemo extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; state = { c: { d: 'd' }, - } + }; static getDerivedStateFromProps() { return { diff --git a/demo/src/childOfPureComponent/index.js b/demo/src/childOfPureComponent/index.js index 8fa03c8a..39642f77 100644 --- a/demo/src/childOfPureComponent/index.js +++ b/demo/src/childOfPureComponent/index.js @@ -23,7 +23,7 @@ export default { } class Main extends React.Component { - state = { clicksCount: 0 } + state = { clicksCount: 0 }; render() { return (
diff --git a/demo/src/cloneElement/index.js b/demo/src/cloneElement/index.js index 798b0af2..c844ea95 100644 --- a/demo/src/cloneElement/index.js +++ b/demo/src/cloneElement/index.js @@ -7,7 +7,7 @@ export default { whyDidYouRender(React); class TestComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; render() { return (
diff --git a/demo/src/createFactory/index.js b/demo/src/createFactory/index.js index 82d679ae..04c0c2dd 100644 --- a/demo/src/createFactory/index.js +++ b/demo/src/createFactory/index.js @@ -7,7 +7,7 @@ export default { whyDidYouRender(React); class TestComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; render() { return (
diff --git a/demo/src/logOwnerReasons/index.js b/demo/src/logOwnerReasons/index.js index b528137c..7600b51d 100644 --- a/demo/src/logOwnerReasons/index.js +++ b/demo/src/logOwnerReasons/index.js @@ -16,7 +16,7 @@ export default { const Owner = () => ; class ClassOwner extends React.Component { - state = { a: 1 } + state = { a: 1 }; componentDidMount() { this.setState({ a: 2 }); } diff --git a/demo/src/noChanges/index.js b/demo/src/noChanges/index.js index 32d6c735..4817b1fb 100644 --- a/demo/src/noChanges/index.js +++ b/demo/src/noChanges/index.js @@ -11,7 +11,7 @@ export default { whyDidYouRender(React); class ClassDemo extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; componentDidMount() { stepLogger('forceUpdate', true); diff --git a/demo/src/specialChanges/index.js b/demo/src/specialChanges/index.js index 8bb21764..c60c3467 100644 --- a/demo/src/specialChanges/index.js +++ b/demo/src/specialChanges/index.js @@ -11,7 +11,7 @@ export default { whyDidYouRender(React); class ClassDemo extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; render() { return
Special Changes
; diff --git a/demo/src/stateChanges/index.js b/demo/src/stateChanges/index.js index 310cb8e5..be6412e7 100644 --- a/demo/src/stateChanges/index.js +++ b/demo/src/stateChanges/index.js @@ -11,11 +11,11 @@ export default { whyDidYouRender(React); class ClassDemo extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; state = { stateKey: 'stateValue', - } + }; componentDidMount() { stepLogger('Set an existing state key with the same value', true); diff --git a/demo/src/strict/index.js b/demo/src/strict/index.js index 4ef85dc2..34e59e89 100644 --- a/demo/src/strict/index.js +++ b/demo/src/strict/index.js @@ -11,7 +11,7 @@ export default { whyDidYouRender(React); class ClassDemo extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; render() { return
Props Changes
; } diff --git a/package.json b/package.json index 6d30021d..799d0751 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@welldone-software/why-did-you-render", - "version": "6.2.1", + "version": "6.2.2", "description": "Monkey patches React to notify you about avoidable re-renders.", "types": "types.d.ts", "main": "dist/whyDidYouRender.js", diff --git a/tests/defaultNotifier.test.js b/tests/defaultNotifier.test.js index 3e60ce29..174aae66 100644 --- a/tests/defaultNotifier.test.js +++ b/tests/defaultNotifier.test.js @@ -5,7 +5,7 @@ import getUpdateInfo from '~/getUpdateInfo'; import whyDidYouRender from '~'; class TestComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; render() { return
hi!
; } @@ -415,7 +415,7 @@ describe('logOnDifferentProps option', () => { whyDidYouRender(React, { onlyLogs: true }); class OwnTestComponent extends React.Component { - static whyDidYouRender = { logOnDifferentValues: true } + static whyDidYouRender = { logOnDifferentValues: true }; render() { return
hi!
; } diff --git a/tests/index.test.js b/tests/index.test.js index 6c77ffe7..07b54a43 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -26,7 +26,7 @@ test('dont swallow errors', () => { ); }; - expect(mountBrokenComponent).toThrow("Cannot read properties of null (reading 'propTypes')"); + expect(mountBrokenComponent).toThrow('Cannot read properties of null (reading \'propTypes\')'); expect(global.flushConsoleOutput()).toEqual([ { @@ -53,7 +53,7 @@ test('dont swallow errors', () => { test('render to static markup', () => { class MyComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; render() { return (
diff --git a/tests/librariesTests/react-router-dom.test.js b/tests/librariesTests/react-router-dom.test.js index c6f792b5..b46d6bd2 100644 --- a/tests/librariesTests/react-router-dom.test.js +++ b/tests/librariesTests/react-router-dom.test.js @@ -113,6 +113,7 @@ describe('react-router-dom-6', () => { const InnerComp = () => { const location = useLocation6(); + // eslint-disable-next-line no-console console.log(`location is: ${location.pathname}`); return ( @@ -125,7 +126,7 @@ describe('react-router-dom-6', () => { const Comp = () => ( - }/> + }/> ); @@ -136,8 +137,8 @@ describe('react-router-dom-6', () => { const consoleOutputs = flushConsoleOutput(); expect(consoleOutputs).toEqual([ - {level: 'log', args: ['location is: /']}, - {level: 'log', args: ['location is: /']}, + { level: 'log', args: ['location is: /'] }, + { level: 'log', args: ['location is: /'] }, ]); expect(updateInfos).toHaveLength(3); @@ -163,6 +164,7 @@ describe('react-router-dom-6', () => { const InnerFn = ({ a, setDeepEqlState }) => { const location = useLocation6(); + // eslint-disable-next-line no-console console.log(`location is: ${location.pathname}`); React.useLayoutEffect(() => { @@ -195,8 +197,8 @@ describe('react-router-dom-6', () => { const consoleOutputs = flushConsoleOutput(); expect(consoleOutputs).toEqual([ - {level: 'log', args: ['location is: /']}, - {level: 'log', args: ['location is: /']}, + { level: 'log', args: ['location is: /'] }, + { level: 'log', args: ['location is: /'] }, ]); expect(updateInfos).toHaveLength(1); diff --git a/tests/logOwnerReasons.test.js b/tests/logOwnerReasons.test.js index 54b15dfe..e0c1c658 100644 --- a/tests/logOwnerReasons.test.js +++ b/tests/logOwnerReasons.test.js @@ -23,7 +23,7 @@ function createOwners(Child) { const Owner = () => ; class ClassOwner extends React.Component { - state = { a: 1 } + state = { a: 1 }; componentDidMount() { this.setState({ a: 2 }); } @@ -241,7 +241,7 @@ describe('logOwnerReasons - function child', () => { describe('logOwnerReasons - class child', () => { class Child extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; render() { return null; } diff --git a/tests/patches/patchClassComponent.test.js b/tests/patches/patchClassComponent.test.js index f300da3e..c4a949b2 100644 --- a/tests/patches/patchClassComponent.test.js +++ b/tests/patches/patchClassComponent.test.js @@ -6,7 +6,7 @@ import whyDidYouRender from '~'; import { diffTypes } from '~/consts'; class TestComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; render() { return
hi!
; } @@ -14,8 +14,8 @@ class TestComponent extends React.Component { const createStateTestComponent = (initialState, newState) => { return class StateTestComponent extends React.Component { - static whyDidYouRender = true - state = initialState + static whyDidYouRender = true; + state = initialState; componentDidMount() { this.setState(newState); } @@ -114,7 +114,7 @@ test('Props change', () => { test('With implemented "componentDidUpdate()"', () => { let innerComponentDidUpdateCalled = false; class OwnTestComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; componentDidUpdate() { innerComponentDidUpdateCalled = true; } @@ -147,13 +147,13 @@ test('With implemented "componentDidUpdate()"', () => { test('With render as an arrow function', () => { class OwnTestComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; componentDidMount() { this.setState({ c: 'c' }); } render = () => { return
hi!
; - } + }; } const { rerender } = rtl.render( @@ -193,7 +193,7 @@ test('With render as an arrow function', () => { test('With render as a binded function', () => { class OwnTestComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; constructor(props, context) { super(props, context); this.render = this.render.bind(this); @@ -269,7 +269,7 @@ test('With implemented "componentDidUpdate()" with a snapshot - not tracked', () test('With implemented "componentDidUpdate()" with a snapshot', () => { let resolve = false; class OwnTestComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; getSnapshotBeforeUpdate() { return true; } diff --git a/tests/shouldTrack.test.js b/tests/shouldTrack.test.js index 90ba84dc..8c8edfb9 100644 --- a/tests/shouldTrack.test.js +++ b/tests/shouldTrack.test.js @@ -4,14 +4,14 @@ import shouldTrack from '~/shouldTrack'; import whyDidYouRender from '~'; class TrackedTestComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; render() { return
hi!
; } } class TrackedTestComponentNoHooksTracking extends React.Component { - static whyDidYouRender = { trackHooks: false } + static whyDidYouRender = { trackHooks: false }; render() { return
hi!
; } @@ -24,7 +24,7 @@ class NotTrackedTestComponent extends React.Component { } class ExcludedTestComponent extends React.Component { - static whyDidYouRender = false + static whyDidYouRender = false; render() { return
hi!
; } diff --git a/tests/strictMode.test.js b/tests/strictMode.test.js index 769fc871..1eb3cdb2 100644 --- a/tests/strictMode.test.js +++ b/tests/strictMode.test.js @@ -5,14 +5,14 @@ import { diffTypes } from '~/consts'; import whyDidYouRender from '~'; class TestComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; render() { return
hi!
; } } class PureTestComponent extends React.PureComponent { - static whyDidYouRender = true + static whyDidYouRender = true; render() { return
hi!
; } diff --git a/tests/utils.test.js b/tests/utils.test.js index 4e36f8c5..1b192fb4 100644 --- a/tests/utils.test.js +++ b/tests/utils.test.js @@ -7,7 +7,7 @@ describe('checkIfInsideAStrictModeTree', () => { test('class component', () => { let isStrictMode; class TestComponent extends React.Component { - static whyDidYouRender = true + static whyDidYouRender = true; render() { isStrictMode = checkIfInsideAStrictModeTree(this); return
hi!
; @@ -41,7 +41,7 @@ describe('checkIfInsideAStrictModeTree', () => { test('pure class component', () => { let isStrictMode; class TestComponent extends React.PureComponent { - static whyDidYouRender = true + static whyDidYouRender = true; render() { isStrictMode = checkIfInsideAStrictModeTree(this); return
hi!
;