0.2.1 • Published 5 years ago

react-interpolate-plugin v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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