Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1955 from quentin-/fix-apollo-provider-children-p…
Browse files Browse the repository at this point in the history
…roptype

Change ApolloProvider children protype from element to node
  • Loading branch information
hwillson authored Jun 21, 2018
2 parents 6f9e844 + 67bfc74 commit 34a42f1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
- [@cherewaty](https://github.com/cherewaty) in [#1951](https://github.com/apollographql/react-apollo/pull/1951)
- Project README has been updated to show a `<Query />` example.
- [@petetnt](https://github.com/petetnt) in [#2102](https://github.com/apollographql/react-apollo/pull/2102)
- The `ApolloProvider` `children` prop type has been changed from `element`
to `node`, to allow multiple children.
- [@quentin-](https://github.com/quentin-) in [#1955](https://github.com/apollographql/react-apollo/pull/1955)

## 2.1.6 (June 19, 2018)

Expand Down
2 changes: 1 addition & 1 deletion src/ApolloProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface ApolloProviderProps<TCache> {
export default class ApolloProvider<TCache> extends Component<ApolloProviderProps<TCache>> {
static propTypes = {
client: PropTypes.object.isRequired,
children: PropTypes.element.isRequired,
children: PropTypes.node.isRequired,
};

static childContextTypes = {
Expand Down
9 changes: 6 additions & 3 deletions test/client/ApolloProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,18 @@ describe('<ApolloProvider /> Component', () => {
// console.error = originalConsoleError;
// });

it('should add the client to the child context', () => {
it('should add the client to the children context', () => {
const tree = TestUtils.renderIntoDocument(
<ApolloProvider client={client}>
<Child />
<Child />
</ApolloProvider>,
) as React.Component<any, any>;

const child = TestUtils.findRenderedComponentWithType(tree, Child);
expect(child.context.client).toEqual(client);
const children = TestUtils.scryRenderedComponentsWithType(tree, Child);

expect(children).toHaveLength(2);
children.forEach(child => expect(child.context.client).toEqual(client));
});

it('should update props when the client changes', () => {
Expand Down

0 comments on commit 34a42f1

Please sign in to comment.