react-interpolate-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

React Interpolate Plugin

Smart interpolation for react components.

Peer Dependencies

  • React >=16.2

API

  • interpolate(key: string, params: Array<any>): string | Array<any> - Interpolate values with specified parameters

How to use

npm i react react-interpolate-plugin
    import React from 'react';
    import interpolate from 'react-interpolate-plugin';
 
    const key = 'Some {0} for {1} {2}.';
    const element = <span>smart</span>;
    const Component = () => <span>interpolation</span>;
    
    const Example = () => {
      return interpolate(key, ['text', element, <Component key="component" />])
    }
 
    
    // Result:
    // Some text for smart interpolation.
    

Test

npm test

License

MIT

Package Sidebar

Install

npm i react-interpolate-plugin

Weekly Downloads

2

Version

0.2.1

License

MIT

Unpacked Size

8.9 kB

Total Files

15

Last publish

Collaborators

  • maxmarinich