Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to react-router 7 #327

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).

## [0.7.0] - 2024-12-05
### Added
* *Nothing*

### Changed
* Update to react-router 7.

### Deprecated
* *Nothing*

### Removed
* Remove support for react-router 6.

### Fixed
* *Nothing*


## [0.6.0] - 2024-10-19
### Added
* *Nothing*
Expand Down
7 changes: 5 additions & 2 deletions dev/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC } from 'react';
import { BrowserRouter, Link, Route, Routes } from 'react-router-dom';
import { BrowserRouter, Link, Route, Routes } from 'react-router';
import { MessagePage } from './block/MessagePage';
import { ResultPage } from './block/ResultPage';
import { SimpleCardPage } from './block/SimpleCardPage';
Expand Down Expand Up @@ -36,7 +36,10 @@ export const App: FC = () => (
<Route path="/form/boolean-controls" element={<BooleanControlsPage />} />
<Route path="/form/search-field" element={<SearchFieldPage />} />
<Route path="/navigation/dropdowns" element={<DropdownsPage />} />
<Route path="/navigation/nav-pills/*" element={<NavPillsPage />} />
<Route path="/navigation/nav-pills">
<Route path="" element={<NavPillsPage />} />
<Route path="*" element={<NavPillsPage />} />
</Route>
<Route path="/ordering/ordering-dropdown" element={<OrderingDropdownPage />} />
<Route path="*" element={<h2 className="text-center">Not found</h2>} />
</Routes>
Expand Down
10 changes: 5 additions & 5 deletions dev/navigation/NavPillsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FC } from 'react';
import { useState } from 'react';
import { Navigate, Route, Routes } from 'react-router-dom';
import { Navigate, Route, Routes } from 'react-router';
import { NavPillItem, NavPills, ToggleSwitch } from '../../src';

export const NavPillsPage: FC = () => {
Expand All @@ -10,15 +10,15 @@ export const NavPillsPage: FC = () => {
<>
<ToggleSwitch checked={fill} onChange={setFill}>Fill</ToggleSwitch>
<NavPills className="mb-3" fill={fill}>
<NavPillItem to="foo">Foo</NavPillItem>
<NavPillItem to="bar">Bar</NavPillItem>
<NavPillItem to="baz">Baz</NavPillItem>
<NavPillItem to="../foo">Foo</NavPillItem>
<NavPillItem to="../bar">Bar</NavPillItem>
<NavPillItem to="../baz">Baz</NavPillItem>
</NavPills>
<Routes>
<Route path="foo" element={<h3 className="text-center">This is option foo</h3>} />
<Route path="bar" element={<h3 className="text-center">This is option bar</h3>} />
<Route path="baz" element={<h3 className="text-center">This is option baz</h3>} />
<Route path="*" element={<Navigate replace to="foo" />} />
<Route path="*" element={<Navigate replace to="../foo" />} />
</Routes>
</>
);
Expand Down
79 changes: 47 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@fortawesome/react-fontawesome": "^0.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.14.2",
"react-router": "^7.0.2",
"reactstrap": "^9.2.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useMemo, useRef, useState } from 'react';
import { useLocation } from 'react-router-dom';
import { useLocation } from 'react-router';
import { parseQueryString } from '../utils';

type ToggleResult = [boolean, () => void, () => void, () => void];
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/NavPills.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FC, PropsWithChildren } from 'react';
import { Children, isValidElement } from 'react';
import { NavLink as RouterNavLink } from 'react-router-dom';
import { NavLink as RouterNavLink } from 'react-router';
import { Card, Nav, NavItem, NavLink } from 'reactstrap';
import './NavPills.scss';

Expand Down
2 changes: 1 addition & 1 deletion test/hooks/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react';
import { createMemoryHistory } from 'history';
import { Router } from 'react-router-dom';
import { Router } from 'react-router';
import { useParsedQuery, useTimeoutToggle } from '../../src';
import { renderWithEvents } from '../__helpers__/setUpTest';

Expand Down
2 changes: 1 addition & 1 deletion test/navigation/NavPills.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';
import { NavPillItem, NavPills } from '../../src';
import { checkAccessibility } from '../__helpers__/accessibility';

Expand Down