@@ -10,7 +10,7 @@ This project tends to use the simplicity of functional React components and the
1010
1111## Usage
1212
13- ``` javascript
13+ ``` jsx
1414import React from ' react' ;
1515import Coroutine from ' react-coroutine' ;
1616import Posts from ' PostAPI' ;
@@ -19,9 +19,9 @@ import PostList from 'PostList.react';
1919async function PostListCo () {
2020 try {
2121 const posts = await Posts .retrieve ();
22- return < PostList posts= {posts} / >
22+ return < PostList posts= {posts} / > ;
2323 } catch (error) {
24- return < p> Unable to fetch posts.< / p>
24+ return < p> Unable to fetch posts.< / p> ;
2525 }
2626}
2727
@@ -34,19 +34,19 @@ For the sake of testability you might want to inject instances into your corouti
3434
3535You are able to provide ` getVariables() ` function that receives ` props ` and ` context ` and returns an object that will be passed in a coroutine.
3636
37- ``` javascript
37+ ``` jsx
3838function getVariables (props ) {
3939 return {
40- postsLoader : new PostsLoader (props .userId )
40+ userPosts : new PostsDAO (props .userId )
4141 };
4242}
4343
44- async function PostListCo ({ postsLoader }) {
44+ async function PostListCo ({ userPosts }) {
4545 try {
46- const posts = await postsLoader .retrieve ();
47- return < PostList posts= {posts} / >
46+ const posts = await userPosts .retrieve ();
47+ return < PostList posts= {posts} / > ;
4848 } catch (error) {
49- return < p> Unable to fetch posts.< / p>
49+ return < p> Unable to fetch posts.< / p> ;
5050 }
5151}
5252
0 commit comments