1.0.1 • Published 10 months ago
@jswork/react-qrcode v1.0.1
react-qrcode
Qr code for react.
installation
npm install -S @jswork/react-qrcode
properties
Name | Type | Required | Default | Description |
---|---|---|---|---|
className | string | false | - | The extended className for component. |
value | string | false | - | The qr value. |
options | object | false | - | The qrcodejs options. |
usage
import css
@import "~@jswork/react-qrcode/dist/style.css"; // or use sass @import "~@jswork/react-qrcode/dist/style.scss"; // customize your styles: $react-qrcode-options: ()
import js
import ReactDemokit from '@jswork/react-demokit'; import React from 'react'; import ReactDOM from 'react-dom'; import ReactQrcode from '@jswork/react-qrcode'; import './assets/style.scss'; class App extends React.Component { state = { value: 'https://www.baidu.com' }; changeValue = () => { console.log('set new value!'); // [195, 217] //(BUG:) https://github.com/davidshimjs/qrcodejs var url = 'https://www.baidu.com&redirect=https%3A%2F%2Fwww.baidu.com%2Findex.html%3Fsdflsjfdjslsdlfjlsdjflksjdfkljsdklfjskldjfklsdjfkljsdklfjskldjfklsdjflssldjflsdjflksjdfljsdlfjsdjf%2Blksdjflksdjfklsjdfkljsdlfjlfjslkdfsdlfjsdlfjsdlfjlsdfjsldfjkljldsfj'.slice( 0, 197 ); // console.log(url.length); this.setState({ value: url }); }; render() { const { value } = this.state; return ( <ReactDemokit className="p-3 app-container" url="https://github.com/afeiship/react-qrcode"> <ReactQrcode value={value} /> <button className="button is-primary my-2" onClick={this.changeValue}> Regenerate </button> </ReactDemokit> ); } } ReactDOM.render(<App />, document.getElementById('app'));
documentation
resources
license
Code released under the MIT license.