diff --git a/packages/redux-devtools-inspector-monitor-test-tab/demo/package.json b/packages/redux-devtools-inspector-monitor-test-tab/demo/package.json index d45d91c1da..8aed33edbb 100644 --- a/packages/redux-devtools-inspector-monitor-test-tab/demo/package.json +++ b/packages/redux-devtools-inspector-monitor-test-tab/demo/package.json @@ -21,7 +21,7 @@ "react-dom": "^17.0.2", "react-is": "^17.0.2", "react-redux": "^7.2.8", - "react-router-dom": "^5.3.1", + "react-router-dom": "^6.3.0", "redux": "^4.2.0", "redux-logger": "^3.0.6", "styled-components": "^5.3.5" @@ -36,7 +36,6 @@ "@types/react": "^17.0.45", "@types/react-dom": "^17.0.16", "@types/react-redux": "^7.1.24", - "@types/react-router-dom": "^5.3.3", "@types/redux-logger": "^3.0.9", "@types/styled-components": "^5.1.25", "@types/webpack-env": "^1.16.4", diff --git a/packages/redux-devtools-inspector-monitor-test-tab/demo/src/DemoApp.tsx b/packages/redux-devtools-inspector-monitor-test-tab/demo/src/DemoApp.tsx index 9646552a2d..5f68b080a2 100644 --- a/packages/redux-devtools-inspector-monitor-test-tab/demo/src/DemoApp.tsx +++ b/packages/redux-devtools-inspector-monitor-test-tab/demo/src/DemoApp.tsx @@ -1,8 +1,8 @@ -import React, { CSSProperties } from 'react'; +import React, { CSSProperties, useRef } from 'react'; import { connect } from 'react-redux'; import { Button, Toolbar, Spacer } from '@redux-devtools/ui'; import pkg from '@redux-devtools/inspector-monitor-test-tab/package.json'; -import { RouteComponentProps, withRouter } from 'react-router-dom'; +import { useLocation } from 'react-router-dom'; import getOptions from './getOptions'; import { DemoAppState } from './reducers'; import { @@ -69,87 +69,84 @@ interface Props shuffleArray: () => void; } -class DemoApp extends React.Component { - timeout?: number; +function DemoApp(props: Props) { + const timeout = useRef(); + const location = useLocation(); - render() { - const options = getOptions(this.props.location); + const options = getOptions(location); - return ( -
-

{pkg.name || Package Name}

-
- {pkg.description || ( - Package Description - )} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- {options.useExtension ? ( - - Disable browser extension - - ) : ( - - Use browser extension - - )} -
-
- ); - } - - toggleTimeoutUpdate = () => { - const enabled = !this.props.timeoutUpdateEnabled; - this.props.toggleTimeoutUpdate(enabled); + const toggleTimeoutUpdate = () => { + const enabled = !props.timeoutUpdateEnabled; + props.toggleTimeoutUpdate(enabled); if (enabled) { - this.timeout = window.setInterval(this.props.timeoutUpdate, 1000); + timeout.current = window.setInterval(props.timeoutUpdate, 1000); } else { - clearTimeout(this.timeout); + clearTimeout(timeout.current); } }; + + return ( +
+

{pkg.name || Package Name}

+
+ {pkg.description || ( + Package Description + )} +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {options.useExtension ? ( + + Disable browser extension + + ) : ( + + Use browser extension + + )} +
+
+ ); } export default connect((state: DemoAppState) => state, { @@ -180,4 +177,4 @@ export default connect((state: DemoAppState) => state, { addFunction: (): AddFunctionAction => ({ type: 'ADD_FUNCTION' }), addSymbol: (): AddSymbolAction => ({ type: 'ADD_SYMBOL' }), shuffleArray: (): ShuffleArrayAction => ({ type: 'SHUFFLE_ARRAY' }), -})(withRouter(DemoApp)); +})(DemoApp); diff --git a/packages/redux-devtools-inspector-monitor-test-tab/demo/src/DevTools.tsx b/packages/redux-devtools-inspector-monitor-test-tab/demo/src/DevTools.tsx index f2988a51e2..fe45c90333 100644 --- a/packages/redux-devtools-inspector-monitor-test-tab/demo/src/DevTools.tsx +++ b/packages/redux-devtools-inspector-monitor-test-tab/demo/src/DevTools.tsx @@ -6,7 +6,7 @@ import { Tab, } from '@redux-devtools/inspector-monitor'; import { DockMonitor } from '@redux-devtools/dock-monitor'; -import { RouteComponentProps, withRouter } from 'react-router-dom'; +import { useLocation } from 'react-router-dom'; import getOptions from './getOptions'; import { TestTab } from '@redux-devtools/inspector-monitor-test-tab'; import { Action } from 'redux'; @@ -36,9 +36,8 @@ export const getDevTools = (location: { search: string }) => ); -const UnconnectedDevTools = ({ location }: RouteComponentProps) => { +export function ConnectedDevTools() { + const location = useLocation(); const DevTools = getDevTools(location); return ; -}; - -export const ConnectedDevTools = withRouter(UnconnectedDevTools); +} diff --git a/packages/redux-devtools-inspector-monitor-test-tab/demo/src/index.tsx b/packages/redux-devtools-inspector-monitor-test-tab/demo/src/index.tsx index 83120306ed..1e3e02034a 100644 --- a/packages/redux-devtools-inspector-monitor-test-tab/demo/src/index.tsx +++ b/packages/redux-devtools-inspector-monitor-test-tab/demo/src/index.tsx @@ -10,7 +10,7 @@ import { StoreEnhancerStoreCreator, } from 'redux'; import logger from 'redux-logger'; -import { BrowserRouter, Route } from 'react-router-dom'; +import { BrowserRouter, Route, Routes } from 'react-router-dom'; import { persistState } from '@redux-devtools/core'; import DemoApp from './DemoApp'; import { rootReducer } from './reducers'; @@ -60,9 +60,9 @@ render( colorPreference: 'auto', }} > - - - + + } /> + {!useDevtoolsExtension && } diff --git a/packages/redux-devtools-inspector-monitor/demo/package.json b/packages/redux-devtools-inspector-monitor/demo/package.json index 899c7e4e1c..4763770455 100644 --- a/packages/redux-devtools-inspector-monitor/demo/package.json +++ b/packages/redux-devtools-inspector-monitor/demo/package.json @@ -20,7 +20,7 @@ "react-bootstrap": "^2.3.1", "react-dom": "^17.0.2", "react-redux": "^7.2.8", - "react-router-dom": "^5.3.1", + "react-router-dom": "^6.3.0", "redux": "^4.2.0", "redux-logger": "^3.0.6" }, @@ -35,7 +35,6 @@ "@types/react": "^17.0.45", "@types/react-dom": "^17.0.16", "@types/react-redux": "^7.1.24", - "@types/react-router-dom": "^5.3.3", "@types/redux-logger": "^3.0.9", "@types/webpack-env": "^1.16.4", "@typescript-eslint/eslint-plugin": "^5.22.0", diff --git a/packages/redux-devtools-inspector-monitor/demo/src/DemoApp.tsx b/packages/redux-devtools-inspector-monitor/demo/src/DemoApp.tsx index fb183e70cc..deea88129c 100644 --- a/packages/redux-devtools-inspector-monitor/demo/src/DemoApp.tsx +++ b/packages/redux-devtools-inspector-monitor/demo/src/DemoApp.tsx @@ -1,4 +1,4 @@ -import React, { CSSProperties } from 'react'; +import React, { CSSProperties, useRef } from 'react'; import { connect } from 'react-redux'; import pkg from '@redux-devtools/inspector-monitor/package.json'; import Button from 'react-bootstrap/Button'; @@ -11,7 +11,7 @@ import InputGroup from 'react-bootstrap/InputGroup'; import Row from 'react-bootstrap/Row'; import * as base16 from 'base16'; import { inspectorThemes } from '@redux-devtools/inspector-monitor'; -import { RouteComponentProps, withRouter } from 'react-router-dom'; +import { useLocation, useNavigate } from 'react-router-dom'; import getOptions, { Options } from './getOptions'; import { AddFunctionAction, @@ -141,129 +141,13 @@ interface Props shuffleArray: () => void; } -class DemoApp extends React.Component { - timeout?: number; +function DemoApp(props: Props) { + const timeout = useRef(); + const location = useLocation(); + const navigate = useNavigate(); - render() { - const options = getOptions(this.props.location); - - return ( -
-

- {pkg.name || Package Name} -

-
- {pkg.description || ( - Package Description - )} -
-
-
-
- - - Theme: - - - - - this.setTheme(options, event.currentTarget.value) - } - > - {themeOptions.map((theme) => ( - - - {options.dark ? 'Light theme' : 'Dark theme'} - - - - -
-
-
-
-
- - - - - - - - - - - - - - - - - -
-
- -
- ); - } - - toggleExtension = () => { - const options = getOptions(this.props.location); + const toggleExtension = () => { + const options = getOptions(location); window.location.href = buildUrl({ ...options, @@ -271,34 +155,147 @@ class DemoApp extends React.Component { }); }; - toggleImmutableSupport = () => { - const options = getOptions(this.props.location); + const toggleImmutableSupport = () => { + const options = getOptions(location); - this.props.history.push( + navigate( buildUrl({ ...options, supportImmutable: !options.supportImmutable }) ); }; - toggleTheme = () => { - const options = getOptions(this.props.location); + const toggleTheme = () => { + const options = getOptions(location); - this.props.history.push(buildUrl({ ...options, dark: !options.dark })); + navigate(buildUrl({ ...options, dark: !options.dark })); }; - setTheme = (options: Options, theme: string) => { - this.props.history.push(buildUrl({ ...options, theme })); + const setTheme = (options: Options, theme: string) => { + navigate(buildUrl({ ...options, theme })); }; - toggleTimeoutUpdate = () => { - const enabled = !this.props.timeoutUpdateEnabled; - this.props.toggleTimeoutUpdate(enabled); + const toggleTimeoutUpdate = () => { + const enabled = !props.timeoutUpdateEnabled; + props.toggleTimeoutUpdate(enabled); if (enabled) { - this.timeout = window.setInterval(this.props.timeoutUpdate, 1000); + timeout.current = window.setInterval(props.timeoutUpdate, 1000); } else { - clearTimeout(this.timeout); + clearTimeout(timeout.current); } }; + + const options = getOptions(location); + + return ( +
+

+ {pkg.name || Package Name} +

+
+ {pkg.description || ( + Package Description + )} +
+
+
+
+ + + Theme: + + + + + setTheme(options, event.currentTarget.value) + } + > + {themeOptions.map((theme) => ( + + + {options.dark ? 'Light theme' : 'Dark theme'} + + + + +
+
+
+
+
+ + + + + + + + + + + + + + + + + +
+
+ +
+ ); } export default connect((state: DemoAppState) => state, { @@ -330,4 +327,4 @@ export default connect((state: DemoAppState) => state, { addFunction: (): AddFunctionAction => ({ type: 'ADD_FUNCTION' }), addSymbol: (): AddSymbolAction => ({ type: 'ADD_SYMBOL' }), shuffleArray: (): ShuffleArrayAction => ({ type: 'SHUFFLE_ARRAY' }), -})(withRouter(DemoApp)); +})(DemoApp); diff --git a/packages/redux-devtools-inspector-monitor/demo/src/DevTools.tsx b/packages/redux-devtools-inspector-monitor/demo/src/DevTools.tsx index cd8a58907d..4042f2a094 100644 --- a/packages/redux-devtools-inspector-monitor/demo/src/DevTools.tsx +++ b/packages/redux-devtools-inspector-monitor/demo/src/DevTools.tsx @@ -5,7 +5,7 @@ import { InspectorMonitor, base16Themes, } from '@redux-devtools/inspector-monitor'; -import { RouteComponentProps, withRouter } from 'react-router-dom'; +import { useLocation } from 'react-router-dom'; import getOptions from './getOptions'; const CustomComponent = () => ( @@ -46,9 +46,8 @@ export const getDevTools = (location: { search: string }) => ); -const UnconnectedDevTools = ({ location }: RouteComponentProps) => { +export function ConnectedDevTools() { + const location = useLocation(); const DevTools = getDevTools(location); return ; -}; - -export const ConnectedDevTools = withRouter(UnconnectedDevTools); +} diff --git a/packages/redux-devtools-inspector-monitor/demo/src/index.tsx b/packages/redux-devtools-inspector-monitor/demo/src/index.tsx index e690bf22a2..3ce6495b69 100644 --- a/packages/redux-devtools-inspector-monitor/demo/src/index.tsx +++ b/packages/redux-devtools-inspector-monitor/demo/src/index.tsx @@ -9,7 +9,7 @@ import { StoreEnhancer, } from 'redux'; import logger from 'redux-logger'; -import { BrowserRouter, Route } from 'react-router-dom'; +import { BrowserRouter, Route, Routes } from 'react-router-dom'; import { persistState } from '@redux-devtools/core'; import DemoApp from './DemoApp'; import { rootReducer } from './reducers'; @@ -52,9 +52,9 @@ const store = createStore(rootReducer, enhancer); render( - - - + + } /> + {!useDevtoolsExtension && } , diff --git a/packages/redux-devtools-rtk-query-monitor/demo/package.json b/packages/redux-devtools-rtk-query-monitor/demo/package.json index f1ceab425c..f9eae22bab 100644 --- a/packages/redux-devtools-rtk-query-monitor/demo/package.json +++ b/packages/redux-devtools-rtk-query-monitor/demo/package.json @@ -26,7 +26,7 @@ "react-icons": "^4.3.1", "react-is": "^17.0.2", "react-redux": "^7.2.8", - "react-router-dom": "^5.3.1", + "react-router-dom": "^6.3.0", "styled-components": "^5.3.5" }, "devDependencies": { @@ -40,7 +40,6 @@ "@types/react": "^17.0.45", "@types/react-dom": "^17.0.16", "@types/react-redux": "^7.1.24", - "@types/react-router-dom": "^5.3.3", "@types/styled-components": "^5.1.25", "@typescript-eslint/eslint-plugin": "^5.22.0", "@typescript-eslint/parser": "^5.22.0", diff --git a/packages/redux-devtools-rtk-query-monitor/demo/src/features/posts/PostDetail.tsx b/packages/redux-devtools-rtk-query-monitor/demo/src/features/posts/PostDetail.tsx index 35ed2cedb0..99811e4978 100644 --- a/packages/redux-devtools-rtk-query-monitor/demo/src/features/posts/PostDetail.tsx +++ b/packages/redux-devtools-rtk-query-monitor/demo/src/features/posts/PostDetail.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { useHistory, useParams } from 'react-router-dom'; +import { useNavigate, useParams } from 'react-router-dom'; import { useDeletePostMutation, useGetPostQuery, @@ -73,13 +73,13 @@ const PostJsonDetail = ({ id }: { id: string }) => { export const PostDetail = () => { const { id } = useParams<{ id: string }>(); - const history = useHistory(); + const navigate = useNavigate(); const toast = useToast(); const [isEditing, setIsEditing] = useState(false); - const { data: post, isLoading } = useGetPostQuery(id); + const { data: post, isLoading } = useGetPostQuery(id!); const [updatePost, { isLoading: isUpdating }] = useUpdatePostMutation(); @@ -106,7 +106,7 @@ export const PostDetail = () => { name={post.name} onUpdate={async (name) => { try { - await updatePost({ id, name }).unwrap(); + await updatePost({ id: id!, name }).unwrap(); } catch { toast({ title: 'An error occurred', @@ -137,9 +137,7 @@ export const PostDetail = () => { {isUpdating ? 'Updating...' : 'Edit'}