feat(examples): update examples to latest library patterns and versions#248
feat(examples): update examples to latest library patterns and versions#248
Conversation
Agent-Logs-Url: https://github.com/forwardsoftware/react-auth/sessions/50c1d7a1-cde2-4433-9288-d2991b5b5dd9 Co-authored-by: panz3r <1754457+panz3r@users.noreply.github.com>
Agent-Logs-Url: https://github.com/forwardsoftware/react-auth/sessions/50c1d7a1-cde2-4433-9288-d2991b5b5dd9 Co-authored-by: panz3r <1754457+panz3r@users.noreply.github.com>
|
@copilot can we also update dependencies in all example packages? We'd like to upgrade to latest version of |
Agent-Logs-Url: https://github.com/forwardsoftware/react-auth/sessions/bbe321d7-346b-4a1e-9a69-64d25a4f02d8 Co-authored-by: panz3r <1754457+panz3r@users.noreply.github.com>
Done in commit Web examples (base, reqres, refresh-token):
Expo example:
The Expo example was kept on React 18 since Expo SDK 54 + React Native 0.81 pins to React 18. Other Expo deps ( All three web examples pass |
There was a problem hiding this comment.
Pull request overview
Updates the examples/* apps to align with newer @forward-software/react-auth usage, modern React/Vite/TypeScript versions, and improves async UI behavior to avoid “stuck loading” states.
Changes:
- Bumped dependencies across examples (notably
@forward-software/react-auth@2.1.0, TypeScript^6.0.0, React/Vite/axios where applicable). - Removed unused legacy entrypoints (
examples/*/index.tsx) and tightened.gitignoreto avoid committing build artifacts/lockfiles. - Fixed
useAsyncCallbackto always reset loading state viatry/finally, and replaced bare-string rejections withErrorobjects.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| examples/reqres/src/Content.tsx | Consolidates React imports and makes useAsyncCallback loading reset robust via try/finally. |
| examples/reqres/src/App.tsx | Updates React import style to match the refreshed example pattern. |
| examples/reqres/package.json | Updates example dependencies to newer React/Vite/TS/auth/axios versions. |
| examples/reqres/index.tsx | Removes unused legacy entrypoint not used by Vite. |
| examples/reqres/.gitignore | Ignores node_modules/, dist/, and package-lock.json to prevent accidental commits. |
| examples/refresh-token/src/auth.ts | Uses Error objects for rejected initialization failures. |
| examples/refresh-token/src/AppContent.tsx | Consolidates React imports and fixes useAsyncCallback loading reset on failure. |
| examples/refresh-token/src/App.tsx | Ensures consistent React typing/import usage for the app component. |
| examples/refresh-token/package.json | Updates example dependencies to newer React/Vite/TS/auth/axios versions. |
| examples/refresh-token/index.tsx | Removes unused legacy entrypoint not used by Vite. |
| examples/refresh-token/.gitignore | Ignores node_modules/, dist/, and package-lock.json to prevent accidental commits. |
| examples/expo/src/hooks/useAsyncCallback.ts | Fixes loading reset on rejected async callbacks via try/finally. |
| examples/expo/src/auth/client.ts | Uses Error objects for rejected initialization failures. |
| examples/expo/package.json | Updates auth/axios/typescript versions while keeping Expo-constrained React version. |
| examples/base/src/Content.tsx | Aligns React import usage and fixes useAsyncCallback loading reset on failure. |
| examples/base/package.json | Updates example dependencies to newer React/Vite/TS/auth versions. |
| examples/base/index.tsx | Removes unused legacy entrypoint not used by Vite. |
| examples/base/.gitignore | Ignores node_modules/, dist/, and package-lock.json to prevent accidental commits. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Affected Package(s)
Related Issue(s)
Motivation
Examples were pinned to
@forward-software/react-auth@2.0.3, TypeScript 5, and older versions of React, Vite, and axios. They also accumulated several code quality issues (dead entry-point files, swallowed async errors, inconsistent import styles).Description of Changes
Dependency bumps (all 4 examples)
@forward-software/react-auth:2.0.3→2.1.0typescript:^5.1.6→^6.0.0Dependency bumps (web examples: base, reqres, refresh-token)
react/react-dom:^18.2.0→^19.2.4@types/react/@types/react-dom:^18.2.21/^18.2.7→^19.0.0vite:^5.0.0→^8.0.3@vitejs/plugin-react:^4.0.0→^6.0.0(required for Vite 8)axios:^1.12.2/1.13.5→^1.14.0Dependency bumps (expo example)
axios:^1.12.2→^1.14.0^18.2.0— Expo SDK 54 + React Native 0.81 are constrained to React 18Dead code removal
index.tsxfrombase,reqres,refresh-token— CRA/IE11 artifacts never referenced by Vite (index.htmlhas always pointed tosrc/main.tsx)Import hygiene
import * as React from 'react'withimport React from 'react'(default import) throughoutimport … from 'react'statements into single declarationsimport typefor type-only symbols (DependencyList)Error handling
Promise.reject("bare string")→Promise.reject(new Error("…"))inrefresh-token/src/auth.tsandexpo/src/auth/client.tsuseAsyncCallbacknow usestry/finallyto guarantee loading-state reset on rejection — previously a failedlogin()/logout()/refresh()call would permanently disable the action button:.gitignoreupdatesnode_modules/,dist/,package-lock.jsontobase,reqres,refresh-tokengitignoresBreaking Changes
None
How to Test
Vitest) and build steps pass successfully on this PR.cd examples/<name> && npm installnpx tsc --noEmit— should pass cleanly under TS 6 + React 19 for all three web examplesnpm run devto exercise the running appChecklist
Notes for Reviewers
No tests added — examples have no test infrastructure by design. TypeScript 6 compilation was verified locally (
tsc --noEmitexits 0 on all three web examples) with React 19, Vite 8, and the updated type packages — no source code changes were required as React 19's breaking changes do not affect the APIs used in these examples. TheuseAsyncCallbackfix applies identically across all four examples; the Expo variant lives in a dedicatedsrc/hooks/useAsyncCallback.tsfile. The Expo example was kept on React 18 as upgrading would require coordinated Expo SDK and React Native version bumps beyond the scope of this PR.Original prompt