Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update constructor docs to include context #168

Closed
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion content/docs/reference-react-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ Beware of this pattern, as state won't be up-to-date with any props update. Inst

If you "fork" props by using them for state, you might also want to implement [`componentWillReceiveProps(nextProps)`](#componentwillreceiveprops) to keep the state up-to-date with them. But lifting state up is often easier and less bug-prone.

> Note
>
> Some libraries, such as React Router, may depend on [context](/docs/context.html) being available. If you implement a constructor and need context, make sure to call `super(props, context)` from the [constructor](/docs/context.html#referencing-context-in-lifecycle-methods).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it sound like you need to use context directly to use React Router which isn't the case. RR ships with components and HOCs that hide the use of context. Can we reword to avoid this impression?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing.


* * *

### `componentWillMount()`
Expand Down Expand Up @@ -269,7 +273,7 @@ A class component becomes an error boundary if it defines this lifecycle method.
For more details, see [*Error Handling in React 16*](/blog/2017/07/26/error-handling-in-react-16.html).

> Note
>
>
> Error boundaries only catch errors in the components **below** them in the tree. An error boundary can’t catch an error within itself.

* * *
Expand Down