diff --git a/src/components/EnvironmentBadge.tsx b/src/components/EnvironmentBadge.tsx index c31677a8f5c3..a3f321072988 100644 --- a/src/components/EnvironmentBadge.tsx +++ b/src/components/EnvironmentBadge.tsx @@ -15,10 +15,10 @@ const ENVIRONMENT_SHORT_FORM = { function EnvironmentBadge() { const styles = useThemeStyles(); - const {environment} = useEnvironment(); + const {environment, isProduction} = useEnvironment(); // If we are on production, don't show any badge - if (environment === CONST.ENVIRONMENT.PRODUCTION || environment === undefined) { + if (isProduction) { return null; } diff --git a/src/components/ExpensifyWordmark.tsx b/src/components/ExpensifyWordmark.tsx index 45c0c9bcef1e..1402b48df0d9 100644 --- a/src/components/ExpensifyWordmark.tsx +++ b/src/components/ExpensifyWordmark.tsx @@ -30,7 +30,7 @@ function ExpensifyWordmark({isSmallScreenWidth, style}: ExpensifyWordmarkProps) const styles = useThemeStyles(); const {environment} = useEnvironment(); // PascalCase is required for React components, so capitalize the const here - const LogoComponent = environment ? logoComponents[environment] : AdHocLogo; + const LogoComponent = logoComponents[environment]; return ( <> diff --git a/src/components/withEnvironment.tsx b/src/components/withEnvironment.tsx index 1bfc147f0db3..6054b43f97f5 100644 --- a/src/components/withEnvironment.tsx +++ b/src/components/withEnvironment.tsx @@ -19,7 +19,10 @@ type EnvironmentContextValue = { environmentURL: string; }; -const EnvironmentContext = createContext(null); +const EnvironmentContext = createContext({ + environment: CONST.ENVIRONMENT.PRODUCTION, + environmentURL: CONST.NEW_EXPENSIFY_URL, +}); function EnvironmentProvider({children}: EnvironmentProviderProps): ReactElement { const [environment, setEnvironment] = useState(CONST.ENVIRONMENT.PRODUCTION); @@ -47,7 +50,7 @@ export default function withEnvironment>, ): (props: Omit & React.RefAttributes) => ReactElement | null { function WithEnvironment(props: Omit, ref: ForwardedRef): ReactElement { - const {environment, environmentURL} = useContext(EnvironmentContext) ?? {}; + const {environment, environmentURL} = useContext(EnvironmentContext); return ( & { +type UseEnvironment = EnvironmentContextValue & { isProduction: boolean; isDevelopment: boolean; }; export default function useEnvironment(): UseEnvironment { - const {environment, environmentURL} = useContext(EnvironmentContext) ?? {}; + const {environment, environmentURL} = useContext(EnvironmentContext); return { environment, environmentURL, diff --git a/src/styles/StyleUtils.ts b/src/styles/StyleUtils.ts index 4b998f940244..aada3a1f70e4 100644 --- a/src/styles/StyleUtils.ts +++ b/src/styles/StyleUtils.ts @@ -462,7 +462,7 @@ function getBorderColorStyle(borderColor: string): ViewStyle { /** * Returns the width style for the wordmark logo on the sign in page */ -function getSignInWordmarkWidthStyle(isSmallScreenWidth: boolean, environment?: ValueOf): ViewStyle { +function getSignInWordmarkWidthStyle(isSmallScreenWidth: boolean, environment: ValueOf): ViewStyle { if (environment === CONST.ENVIRONMENT.DEV) { return isSmallScreenWidth ? {width: variables.signInLogoWidthPill} : {width: variables.signInLogoWidthLargeScreenPill}; }