@storybook/react#action JavaScript Examples
The following examples show how to use
@storybook/react#action.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.stories.js From modern-react-qr-reader with MIT License | 5 votes |
render() {
const { selectFacingMode, selectDelay, legacyMode, onAndOff } = this.props;
return (
<div style={{ width: "400px", margin: "auto" }}>
{onAndOff && (
<button onClick={() => this.setState({ on: !this.state.on })}>
{this.state.on ? "Turn off" : "Turn on"}
</button>
)}
{selectFacingMode && (
<select onChange={e => this.setState({ facingMode: e.target.value })}>
<option value="user">User</option>
<option value="environment">Environment</option>
</select>
)}
{selectDelay && (
<div>
<button onClick={() => this.setState({ delay: false })}>
Disable Delay
</button>
<input
placeholder="Delay in ms"
type="number"
value={this.state.delay}
onChange={e => this.setState({ delay: parseInt(e.target.value) })}
/>
</div>
)}
{this.state.on && (
<Reader
onError={action("Error")}
onScan={action("Scan")}
onLoad={action("Load")}
onImageLoad={action("ImageLoad")}
ref="reader"
facingMode={this.state.facingMode}
legacyMode={legacyMode}
maxImageSize={1000}
delay={this.state.delay}
className="reader-container"
/>
)}
{legacyMode && (
<button onClick={() => this.refs.reader.openImageDialog()}>
Open Image Dialog
</button>
)}
</div>
);
}