UNPKG

foxact

Version:

React Hooks/Utils done right. For browser, SSR, and React Server Components.

2 lines 592 B
'use client'; import{jsx as e}from"react/jsx-runtime";import{memo as r,useState as t}from"react";import{useIsomorphicLayoutEffect as n}from"../use-isomorphic-layout-effect/index.mjs";import"client-only";const o=r(r=>{let{defaultYear:o,...i}=r;"undefined"==typeof window&&void 0===o&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[a,s]=t(o||new Date().getFullYear());return n(()=>{s(new Date().getFullYear())},[]),e("span",{...i,children:a})});"production"!==process.env.NODE_ENV&&(o.displayName="CurrentYear");export{o as CurrentYear};