xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

computer object name

computer object name


  selectOsHandler = (value, type) => {
    this.selectHandlerGenerator(value, type);
  };
  selectVersionHandler = (value, type) => {
    this.selectHandlerGenerator(value, type);
  };
  selectHandlerGenerator = (value, type = ``) => {
    const stateObj = {};
    const payloadObj = {};
    stateObj[`default${type}Option`] = value;
    payloadObj[`active${type}`] = value;
    const {
      dispatch,
    } = this.props;
    this.setState(stateObj, () => {
      dispatch({
        type: `dashboard/update${type}`,
        payload: payloadObj,
      });
      this.props.initData();
    });
  };


pure function components

import React, {
  // Component,
  // useState,
  // useEffect,
} from 'react';

const CommonTitle = (props) => {
  const {
    startDate,
    endDate,
    title,
    style: {
      titleClass,
      textClass,
    },
  } = props;
  return(
    <>
      <p className={titleClass}>
        {title}
      </p>
      <p className={textClass}>
        {`最近一个月 (${startDate} ~ ${endDate})`}
      </p>
    </>
  );
};

export default CommonTitle;

export {
  CommonTitle,
};



import React, {
  // Component,
  // useState,
  // useEffect,
} from 'react';

import {
  Radio,
} from "antd";

const {
  Group: RadioGroup,
  Button: RadioButton,
} = Radio;

const CommonRadioGroup = (props) => {
  const {
    selected,
    radioChangeHanlder,
    tabs,
    radios,
    style,
  } = props;
  return(
    <>
      <RadioGroup
        className="radio-group"
        defaultValue={selected}
        onChange={e => radioChangeHanlder(e)}
        style={style}>
        {
          tabs.map(
            (item, i) => (
              <RadioButton
                className="radio-button"
                value={radios[i]}
                key={radios[i]}>
                {item}
              </RadioButton>
            )
          )
        }
      </RadioGroup>
    </>
  );
};

export default CommonRadioGroup;

export {
  CommonRadioGroup,
};



posted @ 2019-10-16 21:13  xgqfrms  阅读(45)  评论(1编辑  收藏  举报