
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
@bangbu/react-intl-formatted-token
Advanced tools
Components that format data for display
The FormattedTokenAmount
component is an extension for react-intl
, designed to display token amounts with specific formatting rules, especially for very small numbers. It enhances react-intl
's number formatting capabilities by providing a specialized component that leverages decimal.js
for precise calculations.
Install the package using npm or yarn. You'll also need to ensure you have react
and react-intl
installed as peer dependencies.
npm install @bangbu/react-intl-formatted-token
# or
yarn add @bangbu/react-intl-formatted-token
Make sure your project includes react
and react-intl
:
npm install react react-intl
# or
yarn add react react-intl
Prop | Type | Default | Description |
---|---|---|---|
value | number | Required. The numerical value of the token amount. | |
subStyle | React.CSSProperties | Optional. Custom CSS styles to apply to the subscript part when displaying very small numbers (e.g., fontSize ). | |
as | React.ElementType | "span" | Optional. The HTML element type to use as the wrapper for the formatted amount. |
notation | "standard" | "scientific" | "engineering" | "compact" | "standard" | Optional. The notation style to use for formatting the number (from react-intl ). Defaults to standard . |
Here's a concise example of how to use the FormattedTokenAmount
component:
import React from 'react';
import { FormattedTokenAmount } from '@bangbu/react-intl-formatted-token';
import { IntlProvider } from 'react-intl';
const MyComponent = () => {
return (
<IntlProvider locale="en">
<div>
<p>
Small amount: <FormattedTokenAmount value={0.000000123456} />
</p>
<p>
Regular amount: <FormattedTokenAmount value={123.4567} />
</p>
<p>
Customized small amount:
<FormattedTokenAmount
value={0.0000000005}
as="div"
subStyle={{ color: 'blue' }}
/>
</p>
<p>
Compact notation for a large number:
<FormattedTokenAmount value={123456789} notation="compact" />
</p>
</div>
</IntlProvider>
);
};
export default MyComponent;
You can use the as
prop to render the component with React Native's Text
component. This is useful for ensuring consistent text styling within your React Native application.
import React from 'react';
import { FormattedTokenAmount } from '@bangbu/react-intl-formatted-token';
import { IntlProvider } from 'react-intl';
import { Text } from 'react-native'; // Make sure to import Text from react-native
const MyReactNativeScreen = () => {
return (
<IntlProvider locale="en">
{/* Other React Native components */}
<FormattedTokenAmount
value={0.000000789}
as={Text}
subStyle={{ fontSize: 10 }} // Example subStyle for React Native Text
/>
<FormattedTokenAmount
value={12345.6789}
as={Text}
/>
{/* Other React Native components */}
</IntlProvider>
);
};
export default MyReactNativeScreen;
FAQs
Components that format data for display
The npm package @bangbu/react-intl-formatted-token receives a total of 42 weekly downloads. As such, @bangbu/react-intl-formatted-token popularity was classified as not popular.
We found that @bangbu/react-intl-formatted-token demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.