Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

add information about usage with react-redux to the readme #77

Merged
merged 2 commits into from
Sep 13, 2017

Conversation

cweiss-stripe
Copy link
Contributor

@cweiss-stripe cweiss-stripe commented Sep 12, 2017

r? @fred-stripe
cc @michelle

This PR adds some information about the usage of react-stripe-elements together with react-redux to the readme.

This addresses #55

Link to the pretty version: https://github.com/stripe/react-stripe-elements/blob/b2d46f532b48636f8e6c74db26fb15f030096b8b/README.md#troubleshooting

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.
Copy link
Collaborator

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.
Copy link
Collaborator

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:
Copy link
Collaborator

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.
Copy link
Collaborator

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.'

@michelle
Copy link
Collaborator

wording nits!

otherwise lgtm :)

@cweiss-stripe cweiss-stripe merged commit d2c8be1 into master Sep 13, 2017
@cweiss-stripe cweiss-stripe deleted the cw-redux branch September 14, 2017 18:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants