Skip to content

Commit

Permalink
Moving from one governor page to another governor page now triggers s…
Browse files Browse the repository at this point in the history
…etQueryParams.

(Related issue: RickWong/react-transmit#17 )
  • Loading branch information
MrOrz committed Jun 4, 2015
1 parent ce0d5b1 commit 0fbe335
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
26 changes: 16 additions & 10 deletions common/views/Governor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ Governor = Transmit.createContainer(Governor, {
queries: {
governors(queryParams) {
debug("queryParams", queryParams);

if(!queryParams.name){
return Promise.resolve({isLoading: true});
}

return findAll('Governor', {
where: {
name: queryParams.name
Expand Down Expand Up @@ -140,16 +135,27 @@ Governor = Transmit.createContainer(Governor, {

// Setup React-transmit via props
//
var GovernorWrapper = React.createClass({
var GovernorQuerySetter = React.createClass({
_makeQueryParams () {
return {
name: this.props.currentRoute.get('params').get('name')
}
},

render() {
return (
<Governor queryParams={{
name: this.props.currentRoute.get('params').get('name')
}} emptyView={<Loading />}
<Governor queryParams={this._makeQueryParams()} emptyView={<Loading />}
{...this.props}
ref="governor"
/>
);
},

componentDidUpdate(prevProps) {
if(prevProps.currentRoute !== this.props.currentRoute){
this.refs.governor.setQueryParams(this._makeQueryParams());
}
}
})

module.exports = handleRoute(GovernorWrapper);
module.exports = handleRoute(GovernorQuerySetter);
21 changes: 16 additions & 5 deletions common/views/Promise.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,27 @@ PromiseDetail = Transmit.createContainer(PromiseDetail, {

// Setup React-transmit via props
//
var PromiseDetailWrapper = React.createClass({
var PromiseQuerySetter = React.createClass({
_makeQueryParams () {
return {
id: this.props.currentRoute.get('params').get('id')
}
},

render () {
return (
<PromiseDetail queryParams={{
id: this.props.currentRoute.get('params').get('id')
}} emptyView={<Loading />}
<PromiseDetail queryParams={this._makeQueryParams()}
emptyView={<Loading />} ref="promiseDetail"
{...this.props}
/>
);
},

componentDidUpdate(prevProps) {
if(prevProps.currentRoute !== this.props.currentRoute){
this.refs.promiseDetail.setQueryParams(this._makeQueryParams());
}
}
});

module.exports = handleRoute(PromiseDetailWrapper);
module.exports = handleRoute(PromiseQuerySetter);

0 comments on commit 0fbe335

Please sign in to comment.