🎮
FiveM React
  • Welcome
  • Getting Started
    • Installation
  • Hooks
    • useNuiMessage
    • useVisible
    • useNuiData
  • useNuiQuery
  • useNuiMutation
  • Components
    • Visible
    • Link
  • Utils
    • isProduction
    • fetchNui
    • openUrl
    • getResourceName
Powered by GitBook
On this page
  • Overview
  • Usage
  • Importing the Utility
  • Example
  • In Game
  • In Browser
  1. Utils

isProduction

Overview

This utility is designed to help determine whether the application is running in production mode (e.g., a game environment) or development mode (e.g., a browser environment). It provides a simple function that serves as an alternative to repeatedly checking process.env.NODE_ENV === 'production'.

By using this utility, developers can streamline their code and avoid redundant checks, ensuring a cleaner and more maintainable codebase. It is especially useful in distinguishing between different execution environments for various configurations or logging purposes.

Usage

Importing the Utility

import { isProduction } from "@yankes/fivem-react/utils";

Example

In Game

import { useState } from "react"; 
import { isProduction } from "@yankes/fivem-react/utils";

export const MyComponent = () => {
    const [playerName, setPlayerName] = useState<string | null>("john.doe");

    return (
        <div>
            {isProduction() && playerName ? `Hi, ${playerName}!` : "You can see this content only in in game!"} // Hi, john.doe!        
        </div>
    )
}

In Browser

import { useState } from "react"; 
import { isProduction } from "@yankes/fivem-react/utils";

export const MyComponent = () => {
    const [playerName, setPlayerName] = useState<string | null>("john.doe");

    return (
        <div>
            {isProduction() && playerName ? `Hi, ${playerName}!` : "You can see this content only in in game!"} // You can see this content only in in game!        
        </div>
    )
}
PreviousLinkNextfetchNui

Last updated 1 month ago