@feizheng/react-ant-radio-group

2.0.2 • Public • Published

react-ant-radio-group

React ant radio group.

version license size download

installation

npm install -S @feizheng/react-ant-radio-group

update

npm update @feizheng/react-ant-radio-group

properties

Name Type Required Default Description
className string false - The extended className for component.
value any false - Default value.
onChange func false noop The change handler.
items array false [] Value/label pairs.
template func false - The template.

usage

  1. import css
@import "~@feizheng/react-ant-radio-group/dist/style.scss";

// customize your styles:
$react-ant-radio-group-options: ()
  1. import js
import NxOfflineSw from '@feizheng/next-offline-sw';
import ReactGithubCorner from '@feizheng/react-github-corner';
import ReactSwUpdateTips from '@feizheng/react-sw-update-tips';
import { Radio } from 'antd';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactAntRadioGroup from '@feizheng/react-ant-radio-group';
import './assets/style.scss';

class App extends React.Component {
  state = {
    hasUpdate: false,
    items: [
      {
        value: 'k1',
        label: 'k111'
      },
      {
        value: 'k2',
        label: 'k222'
      }
    ]
  };

  componentDidMount() {
    NxOfflineSw.install({
      onUpdateReady: () => {
        this.setState({ hasUpdate: true });
      }
    });
  }

  render() {
    return (
      <div className="p-3 app-container">
        {/* Core components usage start */}
        <div className="is-item mb-4">
          <ReactAntRadioGroup
            onChange={(e) => {
              console.log(e.target.value);
            }}
            items={this.state.items}
          />
        </div>

        <div className="is-item">
          <ReactAntRadioGroup
            buttonStyle="solid"
            defaultValue={'k1'}
            onChange={(e) => {
              console.log(e.target.value);
            }}
            items={this.state.items}
            template={({ item }) => {
              return (
                <Radio.Button value={item.value} key={item.value}>
                  {item.label}
                </Radio.Button>
              );
            }}
          />
        </div>
        {/* Core components usage end */}
        <ReactSwUpdateTips value={this.state.hasUpdate} />
        <ReactGithubCorner value="https://github.com/afeiship/react-ant-radio-group" />
      </div>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('app'));

documentation

license

Code released under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i @feizheng/react-ant-radio-group

Weekly Downloads

2

Version

2.0.2

License

MIT

Unpacked Size

21.1 kB

Total Files

6

Last publish

Collaborators

  • afeiship