Skip to content

Commit

Permalink
Remove react router dom from types
Browse files Browse the repository at this point in the history
JeffGreiner-eaton committed Feb 27, 2024
1 parent 2716304 commit 4be3218
Showing 7 changed files with 14 additions and 39 deletions.
2 changes: 1 addition & 1 deletion login-workflow/docs/API.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ The `RegistrationContextProvider` manages the state of the registration workflow
- Returns an object of functions that are used to manage the registration workflow. See [RegistrationUIActions](#registrationuiactions) for more information.
- **language**: _`string`_
- The language code to use for the registration workflow. This is used to determine which language to use for the UI and for the API calls.
- **navigate**: _`(url: string) => void`_
- **navigate**: _`(destination: -1 | string) => void`_
- A function that is used to navigate to a new URL. This is used to navigate to the various screens of the registration workflow.
- **routeConfig**: _`RouteConfig`_
- An object that defines the various routes for the registration workflow. See [RouteConfig](#routeconfig) for more information.
5 changes: 4 additions & 1 deletion login-workflow/docs/routing.md
Original file line number Diff line number Diff line change
@@ -46,7 +46,10 @@ const getAuthState = () => ({
})

export const AppRouter: React.FC = () => {
const navigate = useNavigate();
const navigation = useNavigate();
const navigate = useCallback((destination: -1 | string) => {
navigation(destination as To);
}, []);
const authState = getAuthState();
return (
<Routes>
9 changes: 6 additions & 3 deletions login-workflow/example/src/navigation/AppRouter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useCallback } from 'react';
import {
AuthContextProvider,
ContactSupportScreen,
@@ -12,7 +12,7 @@ import {
import { useApp } from '../contexts/AppContextProvider';
import { useNavigate } from 'react-router';
import { ProjectAuthUIActions } from '../actions/AuthUIActions';
import { Navigate, Outlet, Route, Routes } from 'react-router-dom';
import { Navigate, Outlet, Route, Routes, To } from 'react-router-dom';
import { Login } from '../screens/Login';
import { ProjectRegistrationUIActions } from '../actions/RegistrationUIActions';
import { routes } from './Routing';
@@ -21,9 +21,12 @@ import i18nAppInstance from '../translations/i18n';
import { ChangePassword } from '../components/ChangePassword';

export const AppRouter: React.FC = () => {
const navigate = useNavigate();
const navigation = useNavigate();
const app = useApp();
const { email, rememberMe } = app.loginData;
const navigate = useCallback((destination: -1 | string) => {
navigation(destination as To);
}, []);

return (
<Routes>
5 changes: 2 additions & 3 deletions login-workflow/src/contexts/AuthContext/types.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
*/

import { i18n } from 'i18next';
import { NavigateFunction } from 'react-router-dom';
import { RouteConfig } from '../../types';
import { ErrorContextProviderProps } from '../ErrorContext/types';

@@ -20,9 +19,9 @@ export type AuthContextProviderProps = {
language: string;

/**
* Function that can be called to navigate to a new route
* A function that is used to navigate to a new URL. This is used to navigate to the various screens of the workflow
*/
navigate: NavigateFunction;
navigate: (destination: -1 | string) => void;

/**
* Object describing the URLs you are using for the relevant routes so the workflow can correctly navigate between screens
3 changes: 1 addition & 2 deletions login-workflow/src/contexts/RegistrationContext/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { i18n } from 'i18next';
import { NavigateFunction } from 'react-router-dom';
import { ErrorContextProviderProps } from '../ErrorContext';
import { RouteConfig } from '../../types';

@@ -80,7 +79,7 @@ export type RegistrationContextProviderProps = {
/**
* A function that is used to navigate to a new URL. This is used to navigate to the various screens of the workflow
*/
navigate: NavigateFunction;
navigate: (destination: -1 | string) => void;

/**
* An object that defines the various routes for the workflow
1 change: 0 additions & 1 deletion login-workflow/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './isFirstRender';
export * from './useQueryString';
28 changes: 0 additions & 28 deletions login-workflow/src/hooks/useQueryString.tsx

This file was deleted.

0 comments on commit 4be3218

Please sign in to comment.