1.0.5 • Published 6 years ago

react-constant-map v1.0.5

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

React-Constant-Map

  • dependence:
    • React16+ 处理基于React的工程中,对于需要异步请求的常量映射(例如:常量编码 -> 文字显示)的关系
  • install
      npm install react-constant-map
  • example

    • ConstantMap.js
      import ReactConstantMapHOC from 'react-constant-map';
    
      const sleep = (t) => new Promise((resolve) => {
        setTimeout(() => {  resolve(); }, t);
      });
    
      async function fakeService() {
        await sleep(2000);
        return {
          1: 'a',
          2: 'b',
          3: 'c',
        };
      }
      
      export default ReactConstantMapHOC(fakeService, 'storeKey');
    • index.js
      import React from 'react';
      import ConstantMap from './ConstantMap.js'
      
      export default function Index(){
        return (
          <div>
            <ConstantMap value="1" />
          </div>
        )
      }
1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago