-
Notifications
You must be signed in to change notification settings - Fork 319
add information about usage with react-redux to the readme #77
Conversation
1010645
to
b2d46f5
Compare
README.md
Outdated
@@ -270,6 +270,30 @@ type FactoryProps = { | |||
}; | |||
``` | |||
|
|||
## Troubleshooting | |||
|
|||
`react-stripe-elements` may not work properly when being used with components that implement `shouldComponentUpdate`. `react-stripe-elements` relies heavily on React's `context` feature and `shouldComponentUpdate` does not provide a way to take context updates into account when deciding whether to allow a re-render and hence can block context updates from reaching components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra word, when being used
-> when used
README.md
Outdated
@@ -270,6 +270,30 @@ type FactoryProps = { | |||
}; | |||
``` | |||
|
|||
## Troubleshooting | |||
|
|||
`react-stripe-elements` may not work properly when being used with components that implement `shouldComponentUpdate`. `react-stripe-elements` relies heavily on React's `context` feature and `shouldComponentUpdate` does not provide a way to take context updates into account when deciding whether to allow a re-render and hence can block context updates from reaching components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: run-on -> "...deciding whether to allow a re-render. These components can block context updates from reaching react-stripe-element
components in the tree."
README.md
Outdated
|
||
`react-stripe-elements` may not work properly when being used with components that implement `shouldComponentUpdate`. `react-stripe-elements` relies heavily on React's `context` feature and `shouldComponentUpdate` does not provide a way to take context updates into account when deciding whether to allow a re-render and hence can block context updates from reaching components. | ||
|
||
For example when using `react-stripe-elements` together with [`react-redux`](https://github.com/reactjs/react-redux) doing the following will not work: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: For example
-> For example,
README.md
Outdated
```js | ||
const Component = connect()(injectStripe(_Component)); | ||
``` | ||
In this case, the context updates originating from the `StripeProvider` are not reaching the components wrapped inside the `connect` function and therefore the behavior of `react-stripe-elements` breaks. The reason is that the `connect` function of `react-redux` [implements `shouldComponentUpdate`](https://github.com/reactjs/react-redux/blob/master/docs/troubleshooting.md#my-views-arent-updating-when-something-changes-outside-of-redux) and blocks re-renders that are triggered by context changes outside of the connected component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: run-on -> 'inside the connect
function. Therefore, react-stripe-elements
components deeper in the tree break.'
wording nits! otherwise lgtm :) |
r? @fred-stripe
cc @michelle
This PR adds some information about the usage of
react-stripe-elements
together withreact-redux
to the readme.This addresses #55
Link to the pretty version: https://github.com/stripe/react-stripe-elements/blob/b2d46f532b48636f8e6c74db26fb15f030096b8b/README.md#troubleshooting