Skip to content

Commit 1fb0c44

Browse files
update context section in docs
1 parent 7d1e16f commit 1fb0c44

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/Details.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,15 @@ Worth mentioning, `for..await` also can be used for producing content over time.
4343
yield <EventInfo event={event} />;
4444
}
4545

46+
## Using context
47+
48+
React Context is [accessible](https://facebook.github.io/react/docs/context.html#referencing-context-in-stateless-functional-components) in the same way as for stateless functional components:
49+
50+
async function* SomeCoroutine(props, context) {
51+
for await (const message of context.dispatcher)
52+
yield <SomeContent message={message} {...props} >;
53+
}
54+
55+
SomeCoroutine.contextTypes = {
56+
dispatcher: () => null
57+
};

0 commit comments

Comments
 (0)