diff --git a/package.json b/package.json index 9e0ed692d..cbb9d5035 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "react-flip-move": "^2.9.14", "react-hot-loader": "^3.1.1", "react-modal": "^1.7.7", - "react-redux": "^5.0.4", + "react-redux": "^5.0.6", "redux": "^3.6.0", "semantic-ui-css": "2.2.10", "sinon": "^1.17.7", diff --git a/web/static/js/app.js b/web/static/js/app.js index 35c56ad74..0f2aacf19 100644 --- a/web/static/js/app.js +++ b/web/static/js/app.js @@ -3,6 +3,7 @@ import React from "react" import { render } from "react-dom" import { bindActionCreators } from "redux" +import { Provider } from "react-redux" import { AppContainer } from "react-hot-loader" import RetroChannel from "./services/retro_channel" @@ -28,7 +29,9 @@ retroChannel.join() render( - + + + , document.querySelector(".react-root") ) @@ -36,12 +39,10 @@ retroChannel.join() // initial render renderWithHotReload() - // ensure rerenders on store updates - store.subscribe(renderWithHotReload) if (module.hot) { // ensure rerenders on module updates - module.hot.accept("./components/remote_retro", renderWithHotReload) + module.hot.accept(() => { renderWithHotReload() }) enableHotCssModuleUpdates() } }) diff --git a/web/static/js/components/remote_retro.jsx b/web/static/js/components/remote_retro.jsx index 20840b84e..012f362ef 100644 --- a/web/static/js/components/remote_retro.jsx +++ b/web/static/js/components/remote_retro.jsx @@ -1,6 +1,6 @@ import React, { Component } from "react" import PropTypes from "prop-types" -import { Provider } from "react-redux" +import { connect } from "react-redux" import * as AppPropTypes from "../prop_types" import Room from "./room" @@ -20,35 +20,46 @@ export class RemoteRetro extends Component { } render() { - const { store, userToken, retroChannel } = this.props - const { users, ideas, stage, insertedAt, alert } = store.getState() + const { users, ideas, userToken, retroChannel, stage, insertedAt, alert } = this.props const currentUser = users.find(user => user.token === userToken) return ( - -
- - - - -
-
+
+ + + + +
) } } RemoteRetro.propTypes = { retroChannel: AppPropTypes.retroChannel.isRequired, - store: PropTypes.object.isRequired, - stage: AppPropTypes.stage.isRequired, + users: AppPropTypes.users, + ideas: AppPropTypes.ideas, userToken: PropTypes.string.isRequired, + stage: AppPropTypes.stage.isRequired, + insertedAt: PropTypes.string, + alert: PropTypes.object, } -export default RemoteRetro +RemoteRetro.defaultProps = { + users: [], + ideas: [], + insertedAt: null, + alert: null, +} + +const mapStateToProps = state => ({ ...state }) + +export default connect( + mapStateToProps +)(RemoteRetro) diff --git a/yarn.lock b/yarn.lock index 6e6c93b22..19308f0b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4714,7 +4714,7 @@ react-proxy@^3.0.0-alpha.0: dependencies: lodash "^4.6.1" -react-redux@^5.0.4: +react-redux@^5.0.6: version "5.0.6" resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.0.6.tgz#23ed3a4f986359d68b5212eaaa681e60d6574946" dependencies: