-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDemoComponent.js
More file actions
44 lines (32 loc) · 1.22 KB
/
DemoComponent.js
File metadata and controls
44 lines (32 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Fullscreenable from '../src/';
export class DemoComponent extends Component {
componentWillReceiveProps(nextProps) {
if (this.props.isFullscreen !== nextProps.isFullscreen) {
// Fullscreen status has changed.
}
}
render() {
const { isFullscreen, toggleFullscreen } = this.props;
const buttonLabel = isFullscreen ? 'Exit Fullscreen' : 'Enter Fullscreen';
const toggleButton = <button onClick={toggleFullscreen}>{buttonLabel}</button>;
return (
<div className="demo-component">
<h1>{DemoComponent.displayName}</h1>
<p>This component is enhanced with Fullscreenable.</p>
{toggleButton}
<h2>Props</h2>
<pre>{JSON.stringify(this.props, null, ' ')}</pre>
</div>
);
}
}
DemoComponent.displayName = 'DemoComponent';
DemoComponent.propTypes = {
isFullscreen: PropTypes.bool,
toggleFullscreen: PropTypes.func,
viewportDimensions: PropTypes.object,
};
const FullscreenableDemoComponent = Fullscreenable()(DemoComponent);
export default FullscreenableDemoComponent;