-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add @bothrs/expo for reusable expo utils, hooks and components #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9efc881
to
0e02d06
Compare
const localUrl: string | undefined = debuggerHostUrl?.split(':').shift() // prettier-ignore | ||
|
||
// Names | ||
const branchName: string | undefined = manifest?.releaseChannel || manifest2?.metadata?.branchName // prettier-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q:
Is this now a thing we do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using branches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's what you mean, I suppose the answer is yes, as classic updates are now no more:
https://docs.expo.dev/archive/classic-updates/introduction/
Classic Updates was a service by Expo that delivered updates to end-users using Expo CLI's expo publish command. It was supported by Expo through August 2022, when it was replaced by EAS Update.
https://docs.expo.dev/versions/latest/sdk/updates/#updatesreleasechannel
I do read that releaseChannel
will always be 'default'
from now on though, so I'll switch the order of these I think (or remove manifest?.releaseChannel
entirely)
f2f78ca
to
5726f7e
Compare
return BRANCH_ENV.production | ||
} | ||
|
||
const branchEnv = getCurrentEnvironment() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this wrapped in a function?
const appName: string | undefined = expoConfig?.name || manifest?.name || manifest2?.name // prettier-ignore | ||
|
||
// Versions | ||
const appVersion: string = expoConfig?.version || manifest?.version || manifest2?.version // prettier-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent naming: appVersion<->version
const { manifest, manifest2, expoConfig, platform } = Constants | ||
|
||
// Local Debugger IP | ||
const debuggerHostUrl: string | undefined = manifest?.debuggerHost || manifest2?.extra?.expoGo?.debuggerHost // prettier-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent naming: debuggerHostUrl<-> debuggerHost
// Versions | ||
const appVersion: string = expoConfig?.version || manifest?.version || manifest2?.version // prettier-ignore | ||
const sdkVersion: string = expoConfig?.sdkVersion || manifest?.sdkVersion || manifest2?.sdkVersion // prettier-ignore | ||
const iosBuildnumber: number | null | undefined = platform?.ios?.buildNumber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent casing of "n": Buildnumber<->buildNumber
|
||
/* --- <ErrorBoundary/> ------------------------------------------------------------------------ */ | ||
|
||
class ErrorBoundary extends React.Component< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider splitting up multiple components in 1 file. This ErrorBoundary is worth to be a component apart from Sentry.
|
||
export type ErrorBoundaryProps = { | ||
children: React.ReactNode | ||
renderErrorScreen: () => JSX.Element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feature request: make this optional and provide a simple error screen with reload button.
|
||
// -- Effects -- | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend to init Sentry in the global scope instead of inside useEffect. In which usecase do you pass dynamic props that would affect Sentry? It looks like there are 3 ways to disable sentry: enabled
, dsn
, silenceEnabledWarnings
. Why is simply setting dsn not enough?
export type BranchConfig = { | ||
devBranches: string[] | ||
stageBranches: string[] | ||
prodBranches: string[] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent dev<->development, stage<->staging, prod<->production
Consider retyping as below to improve consistency:
export type BranchConfig = { | |
devBranches: string[] | |
stageBranches: string[] | |
prodBranches: string[] | |
} | |
export type BranchConfig = Record<BranchEnvironment, string[]> |
What
@bothrs/expo
packageparseConstants()
utilparseGradient()
utilconditionalMarkup()
util<Gradient />
componentuseSvgDimensions()
hook<SentryProvider/>
component<DynamicBottomSheet/>
componentREADME.md
Ticket
[Notion] Identify recurring patterns and ideate solutions for reusability
Demo
yarn workspace @bothrs/expo example start
README
Show README.md content
@bothrs/expo
A set of reusable Expo components, hooks, and utilities for Bothrs projects
Installation
Providers
SentryProvider
A provider that wraps your app with Sentry init and an
ErrorBoundary
component. This is useful for catching errors and reporting them to Sentry.App.tsx
Components
DynamicBottomSheet
A bottom sheet that automatically expands and collapses based on the content inside of it.
App.tsx
SomeScreen.tsx
Gradient
A component that renders a gradient background from a CSS linear gradient string.
Utils
parseGradient
A utility function that parses a CSS linear gradient string and returns an array of colors and locations to use with
expo-linear-gradient
.parseConstants
A utility function that parses the Expo Constants object and returns a new object with only the properties you need, regardles of whether you're in Expo Go, a Dev Client or the Standalone Production App.
Useful to e.g. get the app version and name. Determine which back-end to contact per environment, including your local back-end url in development mode, so you can test on your own device without extra tunnels.
constants.tsx
conditionalMarkup
Helper to avoid ternaries in conditional styled-components styling.
Hooks
useSvgDimensions
SomeSvgIllustration.tsx