react-lsm
Version:
A lightweight react hook for managing localization languages. LSM stands for Localization Storage Manager.
26 lines (23 loc) • 836 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useLsmContext = exports["default"] = exports.LsmContext = void 0;
var _react = require("react");
// Create the global context
var LsmContext = exports.LsmContext = /*#__PURE__*/(0, _react.createContext)(null);
/**
* @description Hook to get the LsmContext values
* @returns {ILsmContextProps} The LsmContext values
* @throws {Error} If the context is not available
*/
var useLsmContext = exports.useLsmContext = function useLsmContext() {
// Get the context from the global context
var context = (0, _react.useContext)(LsmContext);
// Validate that the context is available
if (!context) {
throw new Error("useLsmContext must be used within a LsmProvider");
}
return context;
};
var _default = exports["default"] = LsmContext;
;