Skip to content

Instantly share code, notes, and snippets.

@steida
Last active August 19, 2016 10:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steida/440609d8bd51a04080854c9a5ec9b35e to your computer and use it in GitHub Desktop.
Save steida/440609d8bd51a04080854c9a5ec9b35e to your computer and use it in GitHub Desktop.
Stateless functional component with decorators (not available yet)
import Helmet from 'react-helmet';
import React from 'react';
import linksMessages from '../../common/app/linksMessages';
import { FormattedMessage } from 'react-intl';
import { connect } from 'react-redux';
import { fields } from '../../common/lib/redux-fields';
@fields({
path: 'offline',
fields: [
'somePersistedText',
],
})
@connect(state => ({
online: state.app.online,
}))
const OfflinePage = ({ fields, online }) => (
<div className="offline-page">
<FormattedMessage {...linksMessages.offline}>
{message =>
<Helmet title={message} />
}
</FormattedMessage>
<h2>
Offline
</h2>
<p>
<code>state.app.online: <b>{online.toString()}</b></code>
</p>
<p>
Editable fields are persisted in the local storage by default. But
syncing is hard, so that's why the next field is disabled on offline.
</p>
<input
{...fields.somePersistedText}
disabled={!online}
type="text"
/>
<p>
The user state is also persisted in the local storage. Check{' '}
<code>configureStorage.js</code>.
</p>
<p>TODO: Explain easy immutable offline syncing.</p>
</div>
);
OfflinePage.propTypes = {
fields: React.PropTypes.object.isRequired,
online: React.PropTypes.bool.isRequired,
};
export default OfflinePage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment