ericclemmons / ericclemmons/react-resolver
Using @client and @resolve on the same class causes @resolve to be called twice
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
**Reproduction test case**
```js
import React, {Component} from 'react';
import { resolve, client } from "react-resolver";
import Promise from 'bluebird';
export class SearchPage extends Component {
render() {
console.log("Re-Rendering: ", this.props.user);
return
Prop: {this.props.user}
}
}
// uncomment this and you'll see "Waiting on response" and "Resolving" repeated twice in the console
/*
@client(() => {
return
})
*/
@resolve({
"user": function(props) {
console.log("Waiting on response, ", props);
return new Promise((resolve,reject) => {
setTimeout(() => {
console.log("Resolving");
resolve("ayyyyyy");
}, 5000)
})
}
})
export default class InnerSearchPage extends SearchPage {};
```
**Expected Output**
[with or without server side rendering, eg, React Router switching pages. This is the observed behavior without `@client(...)`]
```
Waiting on response, Object { [abridged] }
Resolving
USER PROP: ayyyyyy
```
**Actual Output**
[with or without server side rendering]
```
Waiting on response, Object { [abridged] }
Resolving
USER PROP: ayyyyyy
Waiting on response, Object { [abridged] }
Resolving
USER PROP: ayyyyyy
```
**Notes**
I'm using server-side rendering, but the behavior is unchanged when I remove `window.__REACT_RESOLVER_PAYLOAD__`.
I am using HOC as a parent of this component.
Some Versions. I don't know how much of this is relevant.
```
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-redux": "^5.0.5",
"react-resolver": "^3.1.0",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
"redux": "^3.7.0",
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.