2.0.2 • Published 4 years ago

@feizheng/react-ant-radio-group v2.0.2

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

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

NameTypeRequiredDefaultDescription
classNamestringfalse-The extended className for component.
valueanyfalse-Default value.
onChangefuncfalsenoopThe change handler.
itemsarrayfalse[]Value/label pairs.
templatefuncfalse-The template.

usage

  1. import css

    @import "~@feizheng/react-ant-radio-group/dist/style.scss";
    
    // customize your styles:
    $react-ant-radio-group-options: ()
  2. 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.

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago