npm.io
0.2.1 • Published 7 years ago

react-interpolate-plugin

Licence
MIT
Version
0.2.1
Deps
0
Size
9 kB
Vulns
0
Weekly
0

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

Keywords