Skip to content

Commit

Permalink
Revert to 'connect'ed RemoteRetro component
Browse files Browse the repository at this point in the history
  - required a change in the parameters passed to module.hot.accept

  gaearon/react-hot-loader#469 (comment)
  • Loading branch information
vanderhoop committed Oct 21, 2017
1 parent 3d655a2 commit 301e662
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 5 additions & 4 deletions web/static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -28,20 +29,20 @@ retroChannel.join()

render(
<AppContainer>
<RemoteRetro retroChannel={retroChannel} userToken={userToken} store={store} />
<Provider store={store} key={Date.now()}>
<RemoteRetro retroChannel={retroChannel} userToken={userToken} />
</Provider>
</AppContainer>,
document.querySelector(".react-root")
)
}

// 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()
}
})
51 changes: 31 additions & 20 deletions web/static/js/components/remote_retro.jsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 (
<Provider store={store}>
<div className={stage}>
<Room
currentUser={currentUser}
users={users}
ideas={ideas}
stage={stage}
retroChannel={retroChannel}
/>
<Alert config={alert} />
<ShareRetroLinkModal retroCreationTimestamp={insertedAt} />
<DoorChime users={users} />
</div>
</Provider>
<div className={stage}>
<Room
currentUser={currentUser}
users={users}
ideas={ideas}
stage={stage}
retroChannel={retroChannel}
/>
<Alert config={alert} />
<ShareRetroLinkModal retroCreationTimestamp={insertedAt} />
<DoorChime users={users} />
</div>
)
}
}

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)
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 301e662

Please sign in to comment.