You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

react-string-format

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-string-format

Formats string using string, number, and react components as paramaters

1.2.0
latest
Source
npm
Version published
Weekly downloads
7.5K
-23.75%
Maintainers
1
Weekly downloads
 
Created
Source

react-string-format

Formats string using string, number, and react components as paramaters

Usage

Installation:

npm install react-string-format

Import

import { format } from 'react-string-format';

String

format('first: {0}; second: {1}', 'hello', 'word');
// result:
'first: hello; second: word'

Number

format('first: {0}; second: {1}', 1, 2);
// result:
'first: 1; second: 2'

React component

format('hiperlink: {0}, span tag: {1}', <a href="#">Click Me</a>, <span>Bla-bla</span>);
// result:
<React.Fragment>
    <React.Fragment key={0}>hiperlink: </React.Fragment>
    <React.Fragment key={1}>
        <a href="#">Click Me</a>
    </React.Fragment>
    <React.Fragment key={2}>, span tag: </React.Fragment>
    <React.Fragment key={3}>
        <span>Bla-bla</span>
    </React.Fragment>
</React.Fragment>

Keywords

format

FAQs

Package last updated on 23 Jan 2024

Did you know?

Socket

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.

Install

Related posts