File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,30 @@ async function* PokemonInfoPage({ pokemonId, pokemonName }) {
4242export default Coroutine .create (PokemonInfoPage);
4343```
4444
45+ ``` javascript
46+ class MyComponent extends Coroutine {
47+ async observe () {
48+ try {
49+ const users = await Users .retrieve ();
50+ return { status: ' success' , users };
51+ } catch (error) {
52+ return { status: ' failure' , error };
53+ }
54+ }
55+
56+ render () {
57+ switch (this .state .data .status ) {
58+ case ' success' :
59+ return < UserList users= {this .state .data .users } / > ;
60+ case ' failure' :
61+ return < ErrorMessage error= {this .state .data .error } / > ;
62+ default :
63+ return < Loading / > ;
64+ }
65+ }
66+ }
67+ ```
68+
4569## Usage
4670
4771See [ details page] ( https://react-coroutine.js.org/Details.html ) for more.
You can’t perform that action at this time.
0 commit comments