How to use the react-instantsearch-dom.connectSearchBox function in react-instantsearch-dom

To help you get started, we’ve selected a few react-instantsearch-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github postmanlabs / postman-docs / src / components / Search / searchPreview.jsx View on Github external
const SearchBox = ({ currentRefinement, refine }) => (
  <div>
    <form role="search" action="" novalidate="">
      <input value="{currentRefinement}" type="search"> refine(event.currentTarget.value)}
      /&gt;
    </form>
  </div>
);

export const CustomSearchBox = connectSearchBox(SearchBox);

// on page load do not display
const Hits = ({ hits }) =&gt; (
  // if parent component set is type, render, otherwise hide
  <ul>
    {hits.length &lt; 1 ? <li>No search results found</li> : ''}
    {hits.map((hit) =&gt; (
      <li>
        <a href="{hit.fields.slug}">
          <span>
          </span></a><p><a href="{hit.fields.slug}">
        </a>
      </p></li>

      //  Work on highlighting
      // /////////////////////////////////////////////////</ul>
github algolia / react-instantsearch / website / examples / e-commerce-infinite / App.js View on Github external
{ value: 'instant_search', label: 'Featured' },
                { value: 'instant_search_price_asc', label: 'Price asc.' },
                { value: 'instant_search_price_desc', label: 'Price desc.' },
              ]}
              defaultRefinement="instant_search"
            /&gt;
          
          
        
        
      
    );
  }
});

const ConnectedSearchBox = connectSearchBox(CustomSearchBox);
const ConnectedHits = connectInfiniteHits(CustomHits);
github wildbit / smtp-field-manual / src / components / search / input.js View on Github external
<form> e.preventDefault()}&gt;
        <input> refine(event.currentTarget.value)}
          type='search'
          placeholder='e.g. 550 or gmail'
          aria-label='Search'
          onFocus={() =&gt; onFocus()}
        /&gt;
        
      
    )
  }
}

export default connectSearchBox(SearchBox)
</form>
github yakovlevyuri / confcitizens / components / SearchBox.tsx View on Github external
const onChangeDebounced = (event: any) =&gt; {
    setState({ value: event.currentTarget.value });
    debounced(refine, event.currentTarget.value);
  };

  return (
    
  );
};

const DebouncedSearchBox = connectSearchBox(SearchBox);

export default DebouncedSearchBox;
github algolia / react-instantsearch / website / examples / material-ui / App.js View on Github external
);
}

function MaterialUiClearAllFilters({ items, refine }) {
  return (
     refine(items)}
      label="Clear All"
      primary
      style={{ height: 48, width: '100%' }}
      className="ClearAll"
    /&gt;
  );
}

const ConnectedSearchBox = connectSearchBox(MaterialUiSearchBox);

const ConnectedCheckBoxRefinementList = connectRefinementList(
  MaterialUiCheckBoxRefinementList
);

const ConnectedNestedList = connectHierarchicalMenu(MaterialUiNestedList);

const ConnectedSortBy = connectSortBy(MaterialUiSortBy);

const ConnectedHits = connectInfiniteHits(CustomHits);

const ConnectedCurrentRefinements = connectCurrentRefinements(
  MaterialUiClearAllFilters
);

export default withURLSync(App);
github algolia / doc-code-samples / React InstantSearch / autocomplete-results-page / src / App.js View on Github external
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import algoliasearch from 'algoliasearch/lite';
import {
  InstantSearch,
  Configure,
  Hits,
  Highlight,
  connectSearchBox,
} from 'react-instantsearch-dom';
import Autocomplete from './Autocomplete';
import './App.css';

const VirtalSearchBox = connectSearchBox(() => null);

const searchClient = algoliasearch(
  'B1G2GM9NG0',
  'aadef574be1f9252bb48d4ea09b5cfe5'
);

class App extends Component {
  state = {
    query: '',
  };

  onSuggestionSelected = (_, { suggestion }) => {
    this.setState({
      query: suggestion.name,
    });
  };
github ChilliCream / hotchocolate / website / src / components / misc / search.tsx View on Github external
document.addEventListener(eventName, detectClickOutside);
    }

    return () =&gt; {
      for (const eventName of eventNames) {
        document.removeEventListener(eventName, detectClickOutside);
      }
    };
  }, [detectClickOutside]);
}

interface SearchBoxProperties extends SearchBoxProvided {
  onFocus: (event: FocusEvent) =&gt; void;
}

const SearchBox = connectSearchBox(
  ({ currentRefinement, onFocus, refine }) =&gt; (
     refine(e.target.value)}
      onFocus={onFocus}
    /&gt;
  )
);

const Results = connectStateResults((comp) =&gt;
  comp.searchResults &amp;&amp; comp.searchResults.nbHits &gt; 0
    ? (comp.children as any)
    : (`No results for '${comp.searchState.query}'` as any)
github algolia / doc-code-samples / React InstantSearch / query-suggestions / src / App.js View on Github external
InstantSearch,
  Configure,
  Hits,
  connectSearchBox,
  connectRefinementList,
} from 'react-instantsearch-dom';
import Autocomplete from './Autocomplete';
import Hit from './Hit';
import './App.css';

const searchClient = algoliasearch(
  'latency',
  '6be0576ff61c053d5f9a3225e2a90f76'
);

const VirtualSearchBox = connectSearchBox(() => null);
const VirtualRefinementList = connectRefinementList(() => null);

class App extends Component {
  state = {
    query: '',
    categories: [],
  };

  onSuggestionSelected = (_, { suggestion }) => {
    const [
      category,
    ] = suggestion.instant_search.facets.exact_matches.categories;

    this.setState({
      query: suggestion.query,
      categories:
github algolia / react-instantsearch / examples / media / App.js View on Github external
&gt;
      <img width="40" src="https://res.cloudinary.com/hilnmyskv/image/upload/w_100,h_100,dpr_2.0//v1461180087/logo-instantsearchjs-avatar.png" alt="React InstantSearch">
    
    <a href="./">
      You
      <i>
    </i></a><i>
    
  
);

const SearchBox = connectSearchBox(({ currentRefinement, refine }) =&gt; (
  <div>
    <div>
      <input value="{currentRefinement}" type="text"> refine(e.target.value)}
        autoComplete="off"
        className="form-control"
      /&gt;
      <span>
        <button>
          <i>
        </i></button><i>
      </i></span><i>
    </i></div><i>
  </i></div></i>
github specfm / spec-next / src / components / Header / Search / SearchInput.js View on Github external
}: any) =&gt; (
   {
      onChange(e);
      refine(e.target.value);
    }}
    placeholder="Search for shows and episodes..."
    showHeaderShadow={showHeaderShadow}
    aria-label="Search"
  /&gt;
);

const ConnectedSearchBox = connectSearchBox(MySearchBox);

export default ConnectedSearchBox;