Skip to content

Commit

Permalink
chore: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
infeng committed Oct 21, 2019
1 parent e7e758a commit cab7747
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Because I can`t be comfortable using [viewerjs](https://github.com/fengyuanchen/

## Installation

> react >= 16.8.0 | react-dom >= 16.8.0
```bash
npm install react-viewer --save
```
Expand All @@ -18,29 +20,20 @@ npm install react-viewer --save
```javascript
import * as React from 'react';
import Viewer from 'react-viewer';
import 'react-viewer/dist/index.css';

class App extends React.Component<any, any> {
constructor() {
super();

this.state = {
visible: false,
};
}

render() {
return (
<div>
<button onClick={() => { this.setState({ visible: !this.state.visible }); } }>show</button>
<Viewer
visible={this.state.visible}
onClose={() => { this.setState({ visible: false }); } }
images={[{src: '', alt: ''}]}
/>
</div>
);
}

function App() {
const [ visible, setVisible ] = React.useState(false);

return (
<div>
<button onClick={() => { setVisible(true); } }>show</button>
<Viewer
visible={visible}
onClose={() => { setVisible(false); } }
images={[{src: '', alt: ''}]}
/>
</div>
);
}
```

Expand Down

0 comments on commit cab7747

Please sign in to comment.