@navojs/react-router 1.0.4 → 1.0.5

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.
Files changed (3) hide show
  1. package/dist/index.js +13 -12
  2. package/package.json +1 -1
  3. package/src/main.tsx +14 -12
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { useContext as useContext2, useMemo as useMemo2 } from "react";
7
7
  import { useMatches } from "react-router";
8
8
 
9
9
  // src/main.tsx
10
- import { createContext, useContext, useMemo, useState } from "react";
10
+ import { createContext, useCallback, useContext, useMemo, useState } from "react";
11
11
  import {
12
12
  Navigate,
13
13
  useLocation
@@ -37,20 +37,21 @@ function NavoProvider({ children, navo }) {
37
37
  authedIdMap: navo.authedIdMap,
38
38
  authedRootResolvePath: navo.authedRootResolvePath
39
39
  });
40
+ const onCanAccess = useCallback((canAccess) => {
41
+ navo.authenticat(canAccess);
42
+ setState({
43
+ nodes: navo.nodes,
44
+ idMap: navo.idMap,
45
+ authedNodes: navo.authedNodes,
46
+ authedIdMap: navo.authedIdMap,
47
+ authedRootResolvePath: navo.authedRootResolvePath
48
+ });
49
+ }, [navo]);
40
50
  const value = useMemo(() => ({
41
51
  ...state,
42
52
  originNavo: navo,
43
- onCanAccess: (canAccess) => {
44
- navo.authenticat(canAccess);
45
- setState({
46
- nodes: navo.nodes,
47
- idMap: navo.idMap,
48
- authedNodes: navo.authedNodes,
49
- authedIdMap: navo.authedIdMap,
50
- authedRootResolvePath: navo.authedRootResolvePath
51
- });
52
- }
53
- }), [navo, state]);
53
+ onCanAccess
54
+ }), [navo, state, onCanAccess]);
54
55
  return /* @__PURE__ */ jsxDEV(NavoContext.Provider, {
55
56
  value,
56
57
  children
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navojs/react-router",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "React Router integration for Navo — declarative navigation and permission-based routing",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/main.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { CanAccess, Navo, NavoNode, NavoNodeInput } from '@navojs/core'
2
- import { createContext, useContext, useMemo, useState } from 'react'
2
+ import { createContext, useCallback, useContext, useMemo, useState } from 'react'
3
3
  import {
4
4
  type BaseRouteObject,
5
5
  Navigate,
@@ -54,22 +54,24 @@ export function NavoProvider<T extends NavoNodeInput[]>({ children, navo }: Navo
54
54
  authedRootResolvePath: navo.authedRootResolvePath,
55
55
  })
56
56
 
57
+ const onCanAccess = useCallback((canAccess?: CanAccess) => {
58
+ navo.authenticat(canAccess)
59
+ setState({
60
+ nodes: navo.nodes,
61
+ idMap: navo.idMap,
62
+ authedNodes: navo.authedNodes,
63
+ authedIdMap: navo.authedIdMap,
64
+ authedRootResolvePath: navo.authedRootResolvePath,
65
+ })
66
+ }, [navo])
67
+
57
68
  const value = useMemo(
58
69
  () => ({
59
70
  ...state,
60
71
  originNavo: navo,
61
- onCanAccess: (canAccess?: CanAccess) => {
62
- navo.authenticat(canAccess)
63
- setState({
64
- nodes: navo.nodes,
65
- idMap: navo.idMap,
66
- authedNodes: navo.authedNodes,
67
- authedIdMap: navo.authedIdMap,
68
- authedRootResolvePath: navo.authedRootResolvePath,
69
- })
70
- },
72
+ onCanAccess,
71
73
  }),
72
- [navo, state]
74
+ [navo, state, onCanAccess]
73
75
  )
74
76
 
75
77
  return <NavoContext.Provider value={value}>{children}</NavoContext.Provider>