This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useReducer } from 'react'; | |
| /** | |
| * There are much better ways to type this | |
| * but this is not the focus of this gist. | |
| */ | |
| interface HTTPState<T> { | |
| status: 'loading' | 'error' | 'success' | |
| error?: string | |
| data?: T |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import express from 'express'; | |
| import Segment from 'analytics-node'; | |
| const instance = new Segment('YOUR_WRITE_KEY'); | |
| const port = 3000; | |
| const app = express(); | |
| // Enables JSON parsing middleware | |
| app.use(express.json()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { instance } from './analytics'; | |
| // These events will be sent to your server instead of Segment's | |
| instance.identify('some-user-id', { customProperty: 'custom value' }); | |
| instance.track('Custom Event', { userId: 'some-user-id' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Segment from "analytics-react-native"; | |
| export const instance = new Segment( | |
| 'YOUR_WRITE_KEY', | |
| { | |
| proxy: { | |
| scheme: 'http', | |
| host: 'localhost', | |
| port: 3000, | |
| path: '/analytics/segment' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Dimensions, StyleSheet } from "react-native"; | |
| const SCALABLE_PROPERTIES = [ | |
| "padding", | |
| "paddingStart", | |
| "paddingEnd", | |
| "paddingTop", | |
| "paddingBottom", | |
| "paddingRight", | |
| "paddingLeft", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <resources> | |
| <!-- Base application theme. --> | |
| <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | |
| <item name="android:windowLightStatusBar">true</item> | |
| <item name="android:statusBarColor">@color/status_bar_color</item> | |
| <item name="android:spinnerItemStyle">@style/SpinnerItem</item> | |
| <item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItem</item> | |
| <!-- Text Underline --> | |
| <item name="android:editTextBackground">@android:color/transparent</item> | |
| <!-- TextInput cursor --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { RefObject } from "react"; | |
| import { FlatList, FlatListProps } from "react-native"; | |
| import Success from "@assets/icons/success.svg"; | |
| import Warning from "@assets/icons/warning.svg"; | |
| import { ColorCode } from "@models/constants/ColorCode"; | |
| import { Row } from "@primitives/Flex/Row"; | |
| import { LocalizedText } from "@primitives/LocalizedText/LocalizedText"; | |
| import { useScrollToTop } from "@react-navigation/native"; | |
| import React, { FC, Fragment, useImperativeHandle, useRef, useState } from "react"; | |
| import { ActivityIndicator, FlatList, StyleSheet } from "react-native"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Wraps the provide component in a `Suspense`, with the provided fallback. | |
| * This should be used on components whose parent is not easy to control, such as | |
| * React Navigation screens to be able to lazy load them using `React.lazy`. | |
| * @param WrappedComponent The component to wrap. | |
| * @param fallback The component to render while loading. | |
| * | |
| * @example | |
| * const SomeScreen = withSuspense(React.lazy(() => import("path/to/some/screen"))); | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component, ComponentType, ReactNode } from "react"; | |
| import crashlytics from "@react-native-firebase/crashlytics"; | |
| export interface ErrorBoundaryProps { | |
| fallback: () => ReactNode; | |
| } | |
| /** | |
| * Wraps the provided component in an ErrorBoundary, with the provided fallback. | |
| * This should be used on components whose parent is not easy to control, such as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/node | |
| /** | |
| * This scripts will create a `env.json` file at the root of the project | |
| * with the content matching that of the desired environment file, as defined in `/src/env/` | |
| * | |
| * @example | |
| * npx ts-node src/scripts/set-environment.ts production | |
| */ |