From 0f6582b270801ee187a73ac25d44338f31cbd883 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Fri, 20 Apr 2018 11:58:56 -0400 Subject: moved from imported client, to Apollo Consumer context --- frontend/components/Search.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'frontend/components/Search.js') diff --git a/frontend/components/Search.js b/frontend/components/Search.js index 399b772..85aaeb5 100644 --- a/frontend/components/Search.js +++ b/frontend/components/Search.js @@ -2,8 +2,8 @@ import Downshift from 'downshift'; import Router from 'next/router'; import styled, { keyframes } from 'styled-components'; import debounce from 'lodash.debounce'; -import { client } from '../lib/withData'; import { SEARCH_ITEMS_QUERY } from '../queries/queries'; +import { ApolloConsumer } from 'react-apollo'; function routeToItem(item) { Router.push({ @@ -62,7 +62,7 @@ class AutoComplete extends React.Component { items: [], loading: false, }; - onChange = debounce(async e => { + onChange = debounce(async (e, client) => { if (!e.target.value) { return this.setState({ items: [] }); } @@ -81,17 +81,21 @@ class AutoComplete extends React.Component { {({ getInputProps, getItemProps, isOpen, inputValue, highlightedIndex }) => (
{/* This is the searchInput */} - { - e.persist(); - this.onChange(e); - }, - })} - /> + + {client => ( + { + e.persist(); + this.onChange(e, client); + }, + })} + /> + )} + {/* This is the Dropdown */} {isOpen && ( -- cgit v1.3