@nexusui/components
Version:
These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.
2 lines (1 loc) • 617 B
JavaScript
import{jsx as t,jsxs as e}from"react/jsx-runtime";import{useState as n,useMemo as o}from"react";import i from"@mui/material/Box";const r=r=>{const{number:c,precision:m}=r,[a,p]=n({coefficient:0,exponent:0});return o((()=>{try{const t=((t,e)=>t.toExponential(e).split("e").map((t=>Number(t))))(c,m);p({coefficient:t[0],exponent:t[1]})}catch(t){console.error("Error in converting number to scientific notation",t)}}),[c,m]),0===c?t(i,{"data-testid":"numInSciNot",children:"0"}):e(i,{"data-testid":"numInSciNot",children:[a.coefficient," x 10",t("sup",{children:a.exponent})]})};export{r as ExponentFormatterComponent};