react-routecharts

1.0.4 • Public • Published

##router-Echarts

##Provides access to the last location in react + react-router (v4.x, v5.x) applications. -❤️ Using hooks? If yes, useLastLocation. -💉 Using HOC? - If yes, withLastLocation. -Handle redirects. -Support TypeScript -Useful for handling internal routing. -Easily prevent leaving your app by users.

//  src/api/grade
export function gradedelete({ id }) {
  return request.post('/grade/delete', { id });
}

##Demo -Edit react-router-last-location

-Note: Last location != Previous browser history state -This library only returns the location that has been active before the recent location change in the current window lifetime.

-This means, it is not equal to the "location that happened before navigating to this history state", or in other words "location to which you'll be redirected upon clicking browser back button".

//  src/view/echarts
import {gradeselect} from '../api/grade'
import echarts from 'echarts'
componentDidMount(){
    gradeselect().then(res=>{
  var myChart = echarts.init(this.refs.main);
      const newdata = res.data.result.map(item=>item.score)
      const newdata1 = res.data.result.map(item=>item.username)
      var option = {}
    myChart.setOption(option);
    })
  }
  render() {
    return (
      <div ref='main' style={{ width: xx, height: xx }}></div>
    );
  }

##Basic usage ###Chaining method if you want to pass a raw RegExp you can, like: Router.when(/^/home$/, ...)

Note the ^ and $, they are automatically added when you pass a string, but in regex you have to define them explicitly.

//  /src/utils/index
export function getSession(key) {
    return window.sessionStorage.getItem(key);
}

export function setSession(key, val) {
    return window.sessionStorage.setItem(key, val);
}

##Keywords With the Es7 spec there will be included the function decorators that use a similar syntax to java's annotations @someDec(asdasd) but untill now you will have to stick to Router.$.

For more examples, see /examples folder.

//  /src/utils/request
import { getSession } from './index';

const request = axios.create({
    timeout: 5000,
});

request.interceptors.request.use(
    config => {
        config.headers.authorization = getSession('token')
        return config;
    },
    error => {
        return Promise.reject(error);
    }
);

request.interceptors.response.use(
    response => {
        return response;
    },
    error => {
        return Promise.reject(error);
    }
);
export default request;

// src/App/main

import { NavLink } from "react-router-dom";
import RouterView from '../router/RouterView';

<NavLink to="/"></NavLink>
<RouterView routes={this.props.routes}></RouterView>

Readme

Keywords

none

Package Sidebar

Install

npm i react-routecharts

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

4.18 kB

Total Files

3

Last publish

Collaborators

  • sinclair-nine