Skip to content

Commit

Permalink
fix: useNavigationItems now accepts options
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklafrance committed Sep 9, 2024
1 parent df9f6b2 commit d46b6d7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/firefly/src/useNavigationItems.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRuntimeNavigationItems } from "@squide/react-router";
import { useRuntimeNavigationItems, type UseRuntimeNavigationItemsOptions } from "@squide/react-router";
import { useAppRouterState } from "./AppRouterContext.ts";

export function useNavigationItems() {
export function useNavigationItems(options?: UseRuntimeNavigationItemsOptions) {
// This is not the most sophisticated strategy but it seems to be good enough for now.
// The idea is that when deferred registrations are used by the consumer applications, the deferred registrations could
// be updated when the global data is updated. If the deferred registrations are updated, it means that the registered
Expand All @@ -12,5 +12,5 @@ export function useNavigationItems() {
// even introducing new module states.
useAppRouterState();

return useRuntimeNavigationItems();
return useRuntimeNavigationItems(options);
}
4 changes: 2 additions & 2 deletions packages/react-router/src/useRuntimeNavigationItems.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useRuntime } from "@squide/core";
import type { ReactRouterRuntime } from "./reactRouterRuntime.ts";

export interface UseNavigationItemsOptions {
export interface UseRuntimeNavigationItemsOptions {
menuId?: string;
}

// This hook has been renamed from useNavigationItems to useRuntimeNavigationItems to free up the name for the
// use useNavigationItems hook of the @squide/firefly package.
export function useRuntimeNavigationItems({ menuId }: UseNavigationItemsOptions = {}) {
export function useRuntimeNavigationItems({ menuId }: UseRuntimeNavigationItemsOptions = {}) {
const runtime = useRuntime() as ReactRouterRuntime;

return runtime.getNavigationItems(menuId);
Expand Down
1 change: 1 addition & 0 deletions samples/basic/host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@react-stately/toast": "3.0.0-beta.4",
"@squide/fakes": "workspace:*",
"@squide/firefly": "workspace:*",
"@tanstack/react-query": "5.51.9",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-router-dom": "6.25.1",
Expand Down
2 changes: 1 addition & 1 deletion samples/endpoints/host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@squide/firefly-webpack-configs": "workspace:*",
"@swc/core": "1.7.0",
"@swc/helpers": "0.5.12",
"@tanstack/react-query": "5.51.9",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@workleap/browserslist-config": "2.0.1",
Expand Down Expand Up @@ -47,6 +46,7 @@
"@squide/fakes": "workspace:*",
"@squide/firefly": "workspace:*",
"@squide/i18next": "workspace:*",
"@tanstack/react-query": "5.51.9",
"i18next": "23.12.1",
"i18next-browser-languagedetector": "8.0.0",
"msw": "2.3.1",
Expand Down

0 comments on commit d46b6d7

Please sign in to comment.