💥 Breaking Change
@grafana/scenes-react,@grafana/scenes- Updating to
react-router@6#979 (@leventebalogh)
- Updating to
Authors: 1
- Levente Balogh (@leventebalogh)
Migration guide for an app plugin
- Bump
react-router-dom-package.json
-"react-router-dom": "^5.2.0",
+"react-router-dom": "^6.22.0",- Remove
@types/react-router-dom-package.json
-"@types/react-router-dom": "^5.2.0",- Stop externalising
react-router-dom-.config/webpack/webpack.config.ts
externals: [
// Required for dynamic publicPath resolution
{ 'amd-module': 'module' },
'lodash',
'jquery',
'moment',
'slate',
'emotion',
'@emotion/react',
'@emotion/css',
'prismjs',
'slate-plain-serializer',
'@grafana/slate-react',
'react',
'react-dom',
'react-redux',
'redux',
'rxjs',
'react-router',
- 'react-router-dom',
'd3',
'angular',
'@grafana/ui',
'@grafana/runtime',
'@grafana/data',- Enable
react-router@v6-.cprc.json
Add the following line in the.cprc.json:
{
"features": {
+ "useReactRouterV6": true
}
}<Route>: use relative wildcard routes
-<Route path="/a/myorg-example-app/home ... />
+<Route path="home/*" ... /><Route>: use theelementprop
-<Route ... component={WithDrilldown} />
+<Route ... element={<WithDrilldown />} /><Switch>: replace withRoutes
-import { Switch } from "react-router-dom";
+import { Routes } from "react-router-dom";
-<Switch> ... </Switch>
+<Routes> ... </Routes>- Add a relative
routePathprop to each<SceneAppPage>. It needs to include a wildcard if there are any drill-down or tab pages under it.
-new SceneAppPage({
- url: "/a/myorg-example-app/home",
- ...
- });
+new SceneAppPage({
+ url: "/a/myorg-example-app/home",
+ routePath: "home/*",
+ ...
+})- Make the
routePathprop defined on drill-downs relative and include a wildcard.