Skip to content

Commit

Permalink
Merge branch 'dev' into brophdawg11/rrr-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Nov 1, 2022
2 parents 055dfe4 + a9b75e8 commit ce34caa
Show file tree
Hide file tree
Showing 28 changed files with 113 additions and 177 deletions.
6 changes: 0 additions & 6 deletions .changeset/cyan-poems-clean.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/fluffy-buttons-push.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/funny-hotels-repeat.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/funny-shirts-admire.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/green-dragons-vanish.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/hot-badgers-grow.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/metal-drinks-melt.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/moody-bulldogs-enjoy.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/nine-apricots-notice.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/ninety-countries-cheat.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/odd-kids-buy.md

This file was deleted.

26 changes: 0 additions & 26 deletions .changeset/pre.json

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/smart-ants-decide.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/weak-lizards-occur.md

This file was deleted.

1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
- underager
- vijaypushkin
- vikingviolinist
- willemarcel
- williamsdyyz
- xavier-lc
- xcsnowcity
Expand Down
2 changes: 2 additions & 0 deletions docs/routers/picking-a-router.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ The easiest way to quickly update to a v6.4 is to get the help from [`createRout
```jsx
import {
createBrowserRouter,
createRoutesFromElements,
Route,
RouterProvider,
} from "react-router-dom";

Expand Down
14 changes: 3 additions & 11 deletions packages/react-router-dom-v5-compat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
# `react-router-dom-v5-compat`

## 6.4.3-pre.1
## 6.4.3

### Patch Changes

- Updated dependencies:
- `react-router@6.4.3-pre.1`
- `react-router-dom@6.4.3-pre.1`

## 6.4.3-pre.0

### Patch Changes

- Updated dependencies:
- `react-router-dom@6.4.3-pre.0`
- `react-router@6.4.3-pre.0`
- `react-router-dom@6.4.3`
- `react-router@6.4.3`

## 6.4.2

Expand Down
4 changes: 2 additions & 2 deletions packages/react-router-dom-v5-compat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-router-dom-v5-compat",
"version": "6.4.3-pre.1",
"version": "6.4.3",
"description": "Migration path to React Router v6 from v4/5",
"keywords": [
"react",
Expand All @@ -24,7 +24,7 @@
"types": "./dist/index.d.ts",
"dependencies": {
"history": "^5.3.0",
"react-router": "6.4.3-pre.1"
"react-router": "6.4.3"
},
"peerDependencies": {
"react": ">=16.8",
Expand Down
21 changes: 7 additions & 14 deletions packages/react-router-dom/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
# `react-router-dom`

## 6.4.3-pre.1
## 6.4.3

### Patch Changes

- Updated dependencies:
- `@remix-run/router@1.0.3-pre.1`
- `react-router@6.4.3-pre.1`

## 6.4.3-pre.0

### Patch Changes

- properly support `index` routes with a `path` in `useResolvedPath` ([#9486](https://github.com/remix-run/react-router/pull/9486))
- Respect `relative=path` prop on `NavLink` ([#9453](https://github.com/remix-run/react-router/pull/9453))
- Fix hrefs generated for `createHashRouter` ([#9409](https://github.com/remix-run/react-router/pull/9409))
- fix encoding/matching issues with special chars ([#9477](https://github.com/remix-run/react-router/pull/9477))
- fix encoding/matching issues with special chars ([#9477](https://github.com/remix-run/react-router/pull/9477), [#9496](https://github.com/remix-run/react-router/pull/9496))
- Properly support `index` routes with a `path` in `useResolvedPath` ([#9486](https://github.com/remix-run/react-router/pull/9486))
- Respect `relative=path` prop on `NavLink` ([#9453](https://github.com/remix-run/react-router/pull/9453))
- Fix `NavLink` behavior for root urls ([#9497](https://github.com/remix-run/react-router/pull/9497))
- Updated dependencies:
- `@remix-run/router@1.0.3-pre.0`
- `react-router@6.4.3-pre.0`
- `@remix-run/router@1.0.3`
- `react-router@6.4.3`

## 6.4.2

Expand Down
51 changes: 51 additions & 0 deletions packages/react-router-dom/__tests__/nav-link-active-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,57 @@ describe("NavLink", () => {

expect(anchors.map((a) => a.props.className)).toEqual(["active", ""]);
});

it("does not automatically apply to root non-layout segments", () => {
let renderer: TestRenderer.ReactTestRenderer;
TestRenderer.act(() => {
renderer = TestRenderer.create(
<MemoryRouter initialEntries={["/home"]}>
<Routes>
<Route index element={<h1>Root</h1>} />
<Route
path="home"
element={<NavLink to="/">Root</NavLink>}
></Route>
</Routes>
</MemoryRouter>
);
});

let anchor = renderer.root.findByType("a");

expect(anchor.props.className).not.toMatch("active");
});

it("does not automatically apply to root layout segments", () => {
let renderer: TestRenderer.ReactTestRenderer;
TestRenderer.act(() => {
renderer = TestRenderer.create(
<MemoryRouter initialEntries={["/home"]}>
<Routes>
<Route
path="/"
element={
<>
<h1>Root</h1>
<Outlet />
</>
}
>
<Route
path="home"
element={<NavLink to="/">Root</NavLink>}
></Route>
</Route>
</Routes>
</MemoryRouter>
);
});

let anchor = renderer.root.findByType("a");

expect(anchor.props.className).not.toMatch("active");
});
});

describe("when it matches just the beginning but not to the end", () => {
Expand Down
44 changes: 28 additions & 16 deletions packages/react-router-dom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -442,24 +442,36 @@ export const NavLink = React.forwardRef<HTMLAnchorElement, NavLinkProps>(
ref
) {
let path = useResolvedPath(to, { relative: rest.relative });
let match = useMatch({ path: path.pathname, end, caseSensitive });

let location = useLocation();
let routerState = React.useContext(DataRouterStateContext);
let nextLocation = routerState?.navigation.location;
let nextPath = useResolvedPath(nextLocation || "");
let nextMatch = React.useMemo(
() =>
nextLocation
? matchPath(
{ path: path.pathname, end, caseSensitive },
nextPath.pathname
)
: null,
[nextLocation, path.pathname, caseSensitive, end, nextPath.pathname]
);

let isPending = nextMatch != null;
let isActive = match != null;
let toPathname = path.pathname;
let locationPathname = location.pathname;
let nextLocationPathname =
routerState && routerState.navigation && routerState.navigation.location
? routerState.navigation.location.pathname
: null;

if (!caseSensitive) {
locationPathname = locationPathname.toLowerCase();
nextLocationPathname = nextLocationPathname
? nextLocationPathname.toLowerCase()
: null;
toPathname = toPathname.toLowerCase();
}

let isActive =
locationPathname === toPathname ||
(!end &&
locationPathname.startsWith(toPathname) &&
locationPathname.charAt(toPathname.length) === "/");

let isPending =
nextLocationPathname != null &&
(nextLocationPathname === toPathname ||
(!end &&
nextLocationPathname.startsWith(toPathname) &&
nextLocationPathname.charAt(toPathname.length) === "/"));

let ariaCurrent = isActive ? ariaCurrentProp : undefined;

Expand Down
6 changes: 3 additions & 3 deletions packages/react-router-dom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-router-dom",
"version": "6.4.3-pre.1",
"version": "6.4.3",
"description": "Declarative routing for React web applications",
"keywords": [
"react",
Expand All @@ -23,8 +23,8 @@
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {
"@remix-run/router": "1.0.3-pre.1",
"react-router": "6.4.3-pre.1"
"@remix-run/router": "1.0.3",
"react-router": "6.4.3"
},
"devDependencies": {
"react": "^18.2.0",
Expand Down
11 changes: 2 additions & 9 deletions packages/react-router-native/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
# `react-router-native`

## 6.4.3-pre.1
## 6.4.3

### Patch Changes

- Updated dependencies:
- `react-router@6.4.3-pre.1`

## 6.4.3-pre.0

### Patch Changes

- Updated dependencies:
- `react-router@6.4.3-pre.0`
- `react-router@6.4.3`

## 6.4.2

Expand Down
4 changes: 2 additions & 2 deletions packages/react-router-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-router-native",
"version": "6.4.3-pre.1",
"version": "6.4.3",
"description": "Declarative routing for React Native applications",
"keywords": [
"react",
Expand All @@ -22,7 +22,7 @@
"types": "./dist/index.d.ts",
"dependencies": {
"@ungap/url-search-params": "^0.1.4",
"react-router": "6.4.3-pre.1"
"react-router": "6.4.3"
},
"devDependencies": {
"react": "^18.2.0",
Expand Down
11 changes: 2 additions & 9 deletions packages/react-router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# `react-router`

## 6.4.3-pre.1
## 6.4.3

### Patch Changes

- `useRoutes` should be able to return `null` when passing `locationArg` ([#9485](https://github.com/remix-run/react-router/pull/9485))
- fix `initialEntries` type in `createMemoryRouter` ([#9498](https://github.com/remix-run/react-router/pull/9498))
- Updated dependencies:
- `@remix-run/router@1.0.3-pre.1`

## 6.4.3-pre.0

### Patch Changes

- Updated dependencies:
- `@remix-run/router@1.0.3-pre.0`
- `@remix-run/router@1.0.3`

## 6.4.2

Expand Down

0 comments on commit ce34caa

Please sign in to comment.