Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot reload #73

Merged
merged 22 commits into from Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -19,3 +19,4 @@ simple*

*.csv
.idea/
.vscode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐱

3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

6 changes: 5 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,14 +2,18 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.15.0] - 2018-11-14
### Added
- Hot reload [#73](https://github.com/plotly/dash-renderer/pull/73)

## [0.14.3] - 2018-10-11
### Fixed
- Included missing polyfills to restore Internet Explorer support [#87](https://github.com/plotly/dash-renderer/issues/87)

## [0.14.2] - 2018-10-11
### Fixed
- Upgraded dependencies to remove warnings
- Restored whatgw-fetch [#87](https://github.com/plotly/dash-renderer/issues/87)
- Restored whatwg-fetch [#87](https://github.com/plotly/dash-renderer/issues/87)
### Added
- Prettier support
- Better ESLint configs
Expand Down
2,919 changes: 1,471 additions & 1,448 deletions dash_renderer/dash_renderer.dev.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dash_renderer/dash_renderer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_renderer/version.py
@@ -1 +1 @@
__version__ = '0.14.3'
__version__ = '0.15.0'
2 changes: 1 addition & 1 deletion dev-requirements.txt
@@ -1,6 +1,6 @@
dash_core_components==0.33.0
dash_html_components==0.11.0rc5
dash==0.28.0
dash==0.29.0
percy
selenium
mock
Expand Down
20 changes: 18 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "dash-renderer",
"version": "0.14.3",
"version": "0.15.0",
"description": "render dash components in react",
"main": "src/index.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions src/AppContainer.react.js
Expand Up @@ -5,6 +5,7 @@ import APIController from './APIController.react';
import DocumentTitle from './components/core/DocumentTitle.react';
import Loading from './components/core/Loading.react';
import Toolbar from './components/core/Toolbar.react';
import Reloader from './components/core/Reloader.react';

function UnconnectedAppContainer() {
return (
Expand All @@ -14,6 +15,7 @@ function UnconnectedAppContainer() {
<APIController />
<DocumentTitle />
<Loading />
<Reloader />
</div>
</Authentication>
);
Expand Down
4 changes: 4 additions & 0 deletions src/actions/api.js
Expand Up @@ -96,3 +96,7 @@ export function login(oauth_token) {
Authorization: `Bearer ${oauth_token}`,
});
}

export function getReloadHash() {
return apiThunk('_reload-hash', 'GET', 'reloadRequest');
}
18 changes: 8 additions & 10 deletions src/components/core/DocumentTitle.react.js
@@ -1,15 +1,15 @@
/* global document:true */

import {connect} from 'react-redux'
import {any} from 'ramda'
import {Component} from 'react'
import {connect} from 'react-redux';
import {any} from 'ramda';
import {Component} from 'react';
import PropTypes from 'prop-types';

class DocumentTitle extends Component {
constructor(props) {
super(props);
this.state = {
initialTitle: document.title
initialTitle: document.title,
};
}

Expand All @@ -31,11 +31,9 @@ class DocumentTitle extends Component {
}

DocumentTitle.propTypes = {
requestQueue: PropTypes.array.isRequired
requestQueue: PropTypes.array.isRequired,
};

export default connect(
state => ({
requestQueue: state.requestQueue
})
)(DocumentTitle);
export default connect(state => ({
requestQueue: state.requestQueue,
}))(DocumentTitle);
25 changes: 10 additions & 15 deletions src/components/core/Loading.react.js
@@ -1,24 +1,19 @@
import {connect} from 'react-redux'
import {any} from 'ramda'
import React from 'react'
import {connect} from 'react-redux';
import {any} from 'ramda';
import React from 'react';
import PropTypes from 'prop-types';

function Loading(props) {
if (any(r => r.status === 'loading', props.requestQueue)) {
return (
<div className="_dash-loading-callback"/>
);
}
return null;

return <div className="_dash-loading-callback" />;
}
return null;
}

Loading.propTypes = {
requestQueue: PropTypes.array.isRequired
requestQueue: PropTypes.array.isRequired,
};

export default connect(
state => ({
requestQueue: state.requestQueue
})
)(Loading);
export default connect(state => ({
requestQueue: state.requestQueue,
}))(Loading);
49 changes: 24 additions & 25 deletions src/components/core/NotifyObservers.react.js
Expand Up @@ -9,14 +9,14 @@ import PropTypes from 'prop-types';
* its child as a prop
*/

function mapStateToProps (state) {
function mapStateToProps(state) {
return {
dependencies: state.dependenciesRequest.content,
paths: state.paths
paths: state.paths,
};
}

function mapDispatchToProps (dispatch) {
function mapDispatchToProps(dispatch) {
return {dispatch};
}

Expand All @@ -37,40 +37,40 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
const payload = {
props: newProps,
id: ownProps.id,
itempath: stateProps.paths[ownProps.id]
itempath: stateProps.paths[ownProps.id],
};

// Update this component's props
dispatch(updateProps(payload));

// Update output components that depend on this input
dispatch(notifyObservers({id: ownProps.id, props: newProps}));
}
}

},
};
}

function NotifyObserversComponent ({
function NotifyObserversComponent({
children,
id,
paths,

dependencies,

fireEvent,
setProps
setProps,
}) {
const thisComponentTriggersEvents = (
dependencies && dependencies.find(dependency => (
const thisComponentTriggersEvents =
dependencies &&
dependencies.find(dependency =>
dependency.events.find(event => event.id === id)
))
);
const thisComponentSharesState = (
dependencies && dependencies.find(dependency => (
dependency.inputs.find(input => input.id === id) ||
dependency.state.find(state => state.id === id)
))
);
);
const thisComponentSharesState =
dependencies &&
dependencies.find(
dependency =>
dependency.inputs.find(input => input.id === id) ||
dependency.state.find(state => state.id === id)
);
/*
* Only pass in `setProps` and `fireEvent` if they are actually
* necessary.
Expand All @@ -87,8 +87,8 @@ function NotifyObserversComponent ({
* or `subscribed_properties` instead of `fireEvent` and `setProps`.
*/
const extraProps = {};
if (thisComponentSharesState &&

if (
thisComponentSharesState &&
// there is a bug with graphs right now where
// the restyle listener gets assigned with a
// setProps function that was created before
Expand All @@ -104,15 +104,14 @@ function NotifyObserversComponent ({

if (!isEmpty(extraProps)) {
return React.cloneElement(children, extraProps);
}
return children;

}
return children;
}

NotifyObserversComponent.propTypes = {
id: PropTypes.string.isRequired,
children: PropTypes.node.isRequired,
path: PropTypes.array.isRequired
path: PropTypes.array.isRequired,
};

export default connect(
Expand Down