Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of change
Packages affected
@clerk/clerk-js
@clerk/clerk-react
@clerk/nextjs
@clerk/types
@clerk/clerk-expo
@clerk/backend-core
@clerk/clerk-sdk-node
@clerk/edge
build/tooling/chore
Description
npm test
runs as expected.npm run build
runs as expected.☝️ Both are failing but unrelated to my changes. The build succeeds for
clerk-expo
package without errors.This fix does two things.
The first is add a guard to check for the existence of
tokenCache.getToken
andtokenCache.saveToken
. Previously, if atokenCache
was passed in, but had different methods on it, e.g.get
/set
, it would attempt to callundefined
functions instead of falling back to thegetTokenFromMemory
andsaveTokenInMemory
operations, which are sensible defaults.The second change here adds an early return if the
tokenCache
is not provided at all. This makes an assumption that the token cache is not available for the web platform, which is the case withexpo-secure-store
that is being used in our clerk-expo-starter.Ideally, we should do better detection of the platform instead of coupling the logic with the
tokenCache
. One option would be to usePlatform.OS === 'web'
provided byreact-native
itself, but that introducesreact-native
as a package dependency.This fix, coupled with changes I recently made to the
clerk-expo-starter
, allow the starter to render on the web without additional changes. It also means we could potentially remove or update this banner in the Docs: