Socket
Book a DemoInstallSign in
Socket

@keystore/react-lib

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keystore/react-lib

keystore react lib

latest
npmnpm
Version
0.0.1-alpha.4
Version published
Maintainers
1
Created
Source

keystore react lib

工具库

Usage

npm i @keystore/react-lib

fetch

import {get, put, post, remove, getJson, putJson, postJson, removeJson} from '@keystore/react-lib/fetch';
get({path, data});
put({path, data, contentType, defaultQuery});
post({path, data, contentType});
remove({path, data, contentType});
  • getJson, putJson, postJson, removeJson对应get,put,post,remove的返回值转成JSON对象

按需加载(code splitting)

import Loadable  from '@keystore/react-lib/loadable';

export default (props) => Loadable({
    view: () => import(/* webpackChunkName: "test" */'./views'),
    reducer: () => import(/* webpackChunkName: "testReducer" */'./reducer'),
    sagas: () => import(/* webpackChunkName: "testSagas" */'./sagas')
},props)
  • reducer和sagas为可选项,非必传
//reducer.js
import * as types from './actionType';
import reducerName from './reducerName'

const initState = {};

const reducer = (state = initState,action) => {
    const {type} = action;
    switch (type) {
        case types.INIT: {
            return {type}
        }
        default: {
            return state;
        }
    }
};

export default {
    [reducerName]: reducer
}

Provider

import React from 'react';
import {render} from 'react-dom';
import Root from './root';
import Provider from '@keystore/react-lib/provider';

render(<Provider root={Root}/>, document.getElementById('app'));

Keywords

keystore

FAQs

Package last updated on 14 Oct 2019

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