Skip to content

Commit

Permalink
fix RouterContext and Router > routeParameterName was not being changed
Browse files Browse the repository at this point in the history
  • Loading branch information
wpdas committed Apr 9, 2024
1 parent a39957d commit 4505eef
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
4 changes: 4 additions & 0 deletions lib/alem-vm/importable/RouteLink.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// NOTA: Arquivo original antes da descoberta e uso do `Link`
// `Link` não está sendo usado pois falha quando se tentar voltar ou ir pra frente
// usando os botoes do navegador

import { LinkProps, navigate, useContext } from "../alem-vm";

/**
Expand Down
9 changes: 1 addition & 8 deletions lib/alem-vm/importable/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ const Router = (props: RouterProps) => {
});
}, [routes]);

// Update the parameter name if needed
useEffect(() => {
if (parameterName && parameterName !== alem.routeParameterName) {
// Comes from RouterProvider
alemRoutes.updateRouteParameterName(parameterName);
}
}, []);

const { routeParameterName, routeType, activeRoute } = alemRoutes;
const routeParamName = parameterName || routeParameterName;

Expand Down Expand Up @@ -128,6 +120,7 @@ const Router = (props: RouterProps) => {
routeParams: _activeRouteParams,
history: _history,
routeBlocked: true,
routeParameterName: routeParamName,
});
}
}
Expand Down
13 changes: 3 additions & 10 deletions lib/alem-vm/importable/RouterContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ const RouterContext = () => {

// ==================================== Routes - Methods ====================================

/**
* Update Route Parameter Name
* @param parameterName
*/
updateRouteParameterName: (parameterName: string) => {
updateAlemRoutesState({
routeParameterName: parameterName,
});
},

/**
* Update route parameters
*/
Expand All @@ -61,6 +51,7 @@ const RouterContext = () => {
routeBlocked?: boolean;
routeParams?: Record<string, any>;
history?: History[]; // Previous history if config.keepRoute is true
routeParameterName?: string;
}) => {
// Update History
const currentHistory = alemRoutesState().history;
Expand Down Expand Up @@ -93,6 +84,8 @@ const RouterContext = () => {
activeRoute: routeProps.activeRoute || alemRoutesState().activeRoute,
routeBlocked: routeProps.routeBlocked || alemRoutesState().routeBlocked,
routeParams: routeProps.routeParams || alemRoutesState().routeParams,
routeParameterName:
routeProps.routeParameterName || alemRoutesState().routeParameterName,
history: updatedHistory,
routesInitialized: true,
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "alem",
"description": "Create web3 applications for NEAR BOS with a focus on performance and friendly development.",
"version": "1.0.0-beta.14",
"version": "1.0.0-beta.15",
"main": "main.js",
"types": "index.d.ts",
"author": "Wenderson Pires - wendersonpires.near",
Expand Down

0 comments on commit 4505eef

Please sign in to comment.