UNPKG

@nimpl/getters

Version:

Implementation of server getters in React Server Components without switching to SSR in next.js

16 lines (15 loc) 662 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.serverGetterInClientComponentError = serverGetterInClientComponentError; const react_1 = __importDefault(require("react")); function serverGetterInClientComponentError(getterName) { if (process.env.NODE_ENV !== "production") { // If useState is defined we're in a client component if (Boolean(react_1.default.useState)) { throw new Error(`${getterName} only works in Server Components`); } } }