Skip to content

feat(examples): update examples to latest library patterns and versions#248

Open
Copilot wants to merge 4 commits intomainfrom
copilot/update-examples-to-latest-pattern
Open

feat(examples): update examples to latest library patterns and versions#248
Copilot wants to merge 4 commits intomainfrom
copilot/update-examples-to-latest-pattern

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

Affected Package(s)

  • Examples

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.32.1.0
  • typescript: ^5.1.6^6.0.0

Dependency 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.0
  • vite: ^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.0

Dependency bumps (expo example)

  • axios: ^1.12.2^1.14.0
  • React kept at ^18.2.0 — Expo SDK 54 + React Native 0.81 are constrained to React 18

Dead code removal

  • Deleted root-level index.tsx from base, reqres, refresh-token — CRA/IE11 artifacts never referenced by Vite (index.html has always pointed to src/main.tsx)

Import hygiene

  • Replaced import * as React from 'react' with import React from 'react' (default import) throughout
  • Consolidated duplicate import … from 'react' statements into single declarations
  • Added import type for type-only symbols (DependencyList)

Error handling

  • Promise.reject("bare string")Promise.reject(new Error("…")) in refresh-token/src/auth.ts and expo/src/auth/client.ts
  • useAsyncCallback now uses try/finally to guarantee loading-state reset on rejection — previously a failed login()/logout()/refresh() call would permanently disable the action button:
// Before — loading stuck on error
const res = await callback(...argsx);
setLoading(false);

// After — always resets
try {
  return await callback(...argsx);
} finally {
  setLoading(false);
}

.gitignore updates

  • Added node_modules/, dist/, package-lock.json to base, reqres, refresh-token gitignores

Breaking Changes

None

How to Test

  1. CI Checks: Verify that all automated tests (Vitest) and build steps pass successfully on this PR.
  2. Local Verification (Optional):
    • cd examples/<name> && npm install
    • npx tsc --noEmit — should pass cleanly under TS 6 + React 19 for all three web examples
    • npm run dev to exercise the running app

Checklist

  • My code follows the project's style guidelines
  • I have added or updated tests to cover the changes
  • I have updated relevant documentation
  • All tests are passing locally
  • CI checks are passing
  • I have reviewed my own code and lock file changes
  • I have checked for any potential security implications
  • I have verified the changes work as expected
  • My commit messages follow Conventional Commits format

Notes for Reviewers

No tests added — examples have no test infrastructure by design. TypeScript 6 compilation was verified locally (tsc --noEmit exits 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. The useAsyncCallback fix applies identically across all four examples; the Expo variant lives in a dedicated src/hooks/useAsyncCallback.ts file. 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

The examples implemented in examples folder are a bit outdated and could use a refresh.

Can you orchestrate the Developer and Code Review sub-agents in a task to improve examples to be updated to latest library pattern and utils?

Note: do not commit dependencies/node_modules or lockfiles from examples, also you are free to use npm instead of pnpm inside each example folder.

Custom agent used: Beppe - Orchestrator
Use when: coordinating a full development cycle across planning, implementation, review, and refinement in this monorepo by delegating to the Developer and Reviewer agents.

Copilot AI changed the title [WIP] Update examples for latest library patterns and utilities feat(examples): update examples to latest library patterns and versions Apr 1, 2026
Copilot AI requested a review from panz3r April 1, 2026 15:38
@panz3r
Copy link
Copy Markdown
Member

panz3r commented Apr 1, 2026

@copilot can we also update dependencies in all example packages?

We'd like to upgrade to latest version of vite (version 8.0.3) and of axios (version 1.14.0), React to version 19.2.4.
Also check other dependencies and suggest those as well if upgrade is feasible.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 1, 2026

@copilot can we also update dependencies in all example packages?

We'd like to upgrade to latest version of vite (version 8.0.3) and of axios (version 1.14.0), React to version 19.2.4.
...

Done in commit 2a2382e. Here's what was updated across all example packages:

Web examples (base, reqres, refresh-token):

Package Before After
react / react-dom ^18.2.0 ^19.2.4
@types/react / @types/react-dom ^18.2.21 / ^18.2.7 ^19.0.0
vite ^5.0.0 ^8.0.3
@vitejs/plugin-react ^4.0.0 ^6.0.0 (requires Vite 8)
axios (reqres, refresh-token) ^1.12.2 / 1.13.5 ^1.14.0

Expo example:

Package Before After
axios ^1.12.2 ^1.14.0

The Expo example was kept on React 18 since Expo SDK 54 + React Native 0.81 pins to React 18. Other Expo deps (jwt-check-expiry, @types/react) are already at their latest versions.

All three web examples pass tsc --noEmit cleanly with the new versions (React 19 + Vite 8 + TS 6 are fully compatible with the existing source code — no breaking changes needed).

@panz3r panz3r requested review from Copilot and removed request for panz3r April 1, 2026 16:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .gitignore to avoid committing build artifacts/lockfiles.
  • Fixed useAsyncCallback to always reset loading state via try/finally, and replaced bare-string rejections with Error objects.

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.

@panz3r panz3r marked this pull request as ready for review April 1, 2026 18:04
@panz3r panz3r requested review from IronTony and panz3r as code owners April 1, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants