Browse Source

Merge pull request #710 from chaficnajjar/patch-1

Fix grammar mistake in higher-order-components.md
main
Alex Krolick 7 years ago
committed by GitHub
parent
commit
43b21efad1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      content/docs/higher-order-components.md

2
content/docs/higher-order-components.md

@ -106,7 +106,7 @@ class BlogPost extends React.Component {
- Inside the listener, call `setState` whenever the data source changes. - Inside the listener, call `setState` whenever the data source changes.
- On unmount, remove the change listener. - On unmount, remove the change listener.
You can imagine that in a large app, this same pattern of subscribing to `DataSource` and calling `setState` will occur over and over again. We want an abstraction that allows us to define this logic in a single place and share them across many components. This is where higher-order components excel. You can imagine that in a large app, this same pattern of subscribing to `DataSource` and calling `setState` will occur over and over again. We want an abstraction that allows us to define this logic in a single place and share it across many components. This is where higher-order components excel.
We can write a function that creates components, like `CommentList` and `BlogPost`, that subscribe to `DataSource`. The function will accept as one of its arguments a child component that receives the subscribed data as a prop. Let's call the function `withSubscription`: We can write a function that creates components, like `CommentList` and `BlogPost`, that subscribe to `DataSource`. The function will accept as one of its arguments a child component that receives the subscribed data as a prop. Let's call the function `withSubscription`:

Loading…
Cancel
Save