ericclemmons / ericclemmons/react-resolver

Using @client and @resolve on the same class causes @resolve to be called twice

Aperta
#128 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
1.6k
Fork
52
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

**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
Loading...

})
*/
@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",
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Riproduci il problema con l’esempio SearchPage fornito, confrontando il comportamento con e senza @client insieme a @resolve. Traccia i punti di ingresso del resolver e del wrapper client per scoprire perché la richiesta viene eseguita due volte; il lavoro è completato quando i log mostrano una chiamata al resolver e una prop user risolta in entrambe le modalità di rendering.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, react
Ambito
frontend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.