'use strict'; import 'whatwg-fetch'; import React from 'react'; export default class InfoStep extends React.Component { constructor (props) { super(props); this.state = { loading: true, info: {} }; } componentDidMount () { let interval; let done = false; let deviceinfo = () => { window.fetch(`${this.props.baseApi}/device-info`).then((res) => { if (res.ok && !done) { done = true; window.clearInterval(interval); return res.json(); } }).then((json) => { this.setState({ loading: false, info: json }); }); }; interval = window.setInterval(deviceinfo, 5 * 1000); deviceinfo(); } handleNextButton (e) { e.preventDefault(); this.props.nextStep(); } render () { return (
{(() => { if (this.state.loading) { return (
Loading Gathering device information...
); } else { return (

Here are some information about the device you are about to configure:

{ this.handleNextButton(e); } }>Next
); } })()}
); } } if (process.env.NODE_ENV !== 'production') { // for Preact InfoStep.propTypes = { baseApi: React.PropTypes.string.isRequired, nextStep: React.PropTypes.func.isRequired }; }