@skbkontur/side-menu 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.7.1](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.7.0...@skbkontur/side-menu@0.7.1) (2023-03-13)
7
+
8
+ **Note:** Version bump only for package @skbkontur/side-menu
9
+
10
+
11
+
12
+
13
+
6
14
  # [0.7.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.6.2...@skbkontur/side-menu@0.7.0) (2023-03-03)
7
15
 
8
16
 
package/README.md CHANGED
@@ -642,3 +642,59 @@ const items = [
642
642
  }
643
643
  }
644
644
  ```
645
+
646
+
647
+ ### Роутинг
648
+
649
+ Компонент `SideMenu.Link` можно использовать, например, вместе с `react-router-dom`.
650
+
651
+ Для этого можно сделать подобную обёртку:
652
+
653
+
654
+ ```ts static
655
+ // react-router-dom v6
656
+ import { useNavigate } from "react-router-dom";
657
+
658
+ interface SideMuneReLinkProps extends SideMenuLinkProps {
659
+ href: string;
660
+ }
661
+
662
+ const SideMuneReLink: React.FunctionComponent<SideMuneReLinkProps> = (
663
+ props
664
+ ) => {
665
+ const navigate = useNavigate();
666
+
667
+ return (
668
+ <SideMenu.Link
669
+ {...props}
670
+ onClick={(e) => {
671
+ e.preventDefault();
672
+ navigate(props.href);
673
+ }}
674
+ />
675
+ );
676
+ };
677
+ ```
678
+
679
+ Пример `v6` в [песочнице](https://codesandbox.io/s/side-menu-react-router-dom-v6-4cl188?file=/src/App.tsx).
680
+
681
+ ---
682
+
683
+ В предыдущей мажорной версии хук назывался иначе - `useHistory`.
684
+
685
+ ```ts static
686
+ // react-router-dom v5
687
+ import { useHistory } from "react-router-dom";
688
+ ```
689
+
690
+
691
+ Пример `v5` в [песочнице](https://codesandbox.io/s/side-menu-react-router-dom-v5-0ipgj4?file=/src/App.tsx).
692
+
693
+
694
+ В самом пакете `react-router-dom v5` обработчик клика немного умнее.
695
+ Например, он игнорирует клики с модификаторами, чтобы ссылка отрабатывала привычным способом.
696
+
697
+ Детали реализации можно посмотреть здесь: https://github.com/remix-run/react-router/blob/v5/packages/react-router-dom/modules/Link.js#L36
698
+
699
+
700
+ При необходимости вы можете повторить часть этой логики в своей обёртке.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skbkontur/side-menu",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"