JSPM

@seaofvoices/react-lua-use-constant

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q71400F
  • License MIT

Package Exports

  • @seaofvoices/react-lua-use-constant
  • @seaofvoices/react-lua-use-constant/src/init.lua

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@seaofvoices/react-lua-use-constant) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

checks version GitHub top language license npm

ko-fi

react-lua-use-constant

A react-lua hook to create a value once. It is different from useMemo, which can potentially re-calculate its value.

Installation

Add react-lua-use-constant in your dependencies:

yarn add @seaofvoices/react-lua-use-constant

Or if you are using npm:

npm install @seaofvoices/react-lua-use-constant

Usage

This hook takes an initializer function that gets called once to obtain the constant value.

local useConstant = require('@pkg/@seaofvoices/react-lua-use-constant')

local function Component(props)
    local mountTime = useConstant(function()
        return os.time()
    end)

    return ...
end

Other Lua Environments Support

If you would like to use this library on a Lua environment, where it is currently incompatible, open an issue (or comment on an existing one) to request the appropriate modifications.

The library uses darklua to process its code.

License

This project is available under the MIT license. See LICENSE.txt for details.