How to use the algoliasearch/reactnative function in algoliasearch

To help you get started, we’ve selected a few algoliasearch 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 bayesimpact / bob-emploi / frontend / client / src / components / suggestions.tsx View on Github external
function fetchJob(jobName: string, jobId: string): Promise {
  const algoliaClient = algoliasearch(JobSuggest.algoliaApp, JobSuggest.algoliaApiKey)
  const jobIndex = algoliaClient.initIndex(JobSuggest.algoliaIndex)
  // First fetch by name.
  return jobIndex.search(jobName).
    // Check the code OGR is right (if given)
    then(getFirstHitWithCodeOgr(jobId)).
    // If nothing found, fetch by code OGR.
    then((hit): Promise => hit ? Promise.resolve(hit) :
      jobIndex.search(jobId).then(getFirstHitWithCodeOgr(jobId))).
    then(jobFromSuggestion)
}
github birkir / react-native-appstore / src / store / index.js View on Github external
if (__DEV__) {
  // This becomes handy to debug network requests in Chrome DevTools
  XMLHttpRequest = GLOBAL.originalXMLHttpRequest
    ? GLOBAL.originalXMLHttpRequest
    : GLOBAL.XMLHttpRequest;
}
/* eslint-enable */

// Create new Apollo client
const client = new ApolloClient({
  link: new HttpLink({ uri: config.API_URL }),
  cache: new InMemoryCache(),
});

// Algolia client
const algolia = algoliasearch(config.ALGOLIA_APP_ID, config.ALGOLIA_API_KEY);

export default class Store {

  ui = new UI();

  algolia = {
    client: algolia,
    apps: algolia.initIndex('apps'),
  };

  async setup() {
    return true;
  }
}

/**
github bayesimpact / bob-emploi / frontend / client / src / components / suggestions.tsx View on Github external
public componentDidMount(): void {
    const {
      algoliaApp,
      algoliaApiKey,
      algoliaIndex,
      display,
      displayValue,
      hitsPerPage,
      onChange,
      onSuggestSelect,
      suggestionTemplate,
      ...extraProps
    } = this.props
    const algoliaClient = algoliasearch(algoliaApp, algoliaApiKey)
    const displayFunc = display ||
      ((suggestion): React.ReactNode => this.props.displayKey && suggestion[this.props.displayKey])
    const handleSelected = (event, suggestion): void => {
      const displaySuggestion = displayFunc(suggestion)
      onSuggestSelect && onSuggestSelect(event, displaySuggestion, suggestion)
      onChange && onChange(event, displaySuggestion, suggestion)
    }
    // TODO(pascal): Rething this pattern as this is not compatible with React.
    // Modifying the DOM without React is somewhat OK, but here it changes the
    // main DOM element of this component which confuses React when trying to
    // update the components before it.
    const suggest = autocomplete(this.node.current, extraProps, [
      {
        display: displayFunc,
        source: autocomplete.sources.hits(
          algoliaClient.initIndex(algoliaIndex), {hitsPerPage: hitsPerPage}),
github bayesimpact / bob-emploi / frontend / client / src / components / suggestions.tsx View on Github external
function fetchFirstSuggestedJob(jobName: string): Promise {
  const algoliaClient = algoliasearch(JobSuggest.algoliaApp, JobSuggest.algoliaApiKey)
  const jobIndex = algoliaClient.initIndex(JobSuggest.algoliaIndex)
  return jobIndex.search(jobName).then((results): bayes.bob.Job|null => {
    const firstJobSuggestion = results.hits && results.hits[0]
    if (!firstJobSuggestion) {
      return null
    }
    const firstSuggestedJob = jobFromSuggestion(firstJobSuggestion)
    // TODO(florian): Check that the job has the expected RomeId.
    return firstSuggestedJob
  })
}
github hummingbird-me / kitsu-mobile / src / screens / Feed / components / MediaModal / component.js View on Github external
doSearch = (query, page) => {
    const { apiKey, indexName } = this.state;
    if (!apiKey) return;

    const algoliaClient = algolia(kitsuConfig.algoliaAppId, apiKey);
    const algoliaIndex = algoliaClient.initIndex(indexName);

    algoliaIndex.setSettings({
      attributesToRetrieve: [
        'id',
        'slug',
        'kind',
        'canonicalTitle',
        'titles',
        'posterImage',
        'subtype',
        'chapterCount',
        'episodeCount',
        'synopsis',
      ],
    });
github bayesimpact / bob-emploi / frontend / client / src / components / suggestions.tsx View on Github external
function fetchCity(location: bayes.bob.FrenchCity): Promise {
  const algoliaClient = algoliasearch(ALGOLIA_APP, ALGOLIA_API_KEY)
  const {departementId, cityId, name: cityName} = location
  const cityIndex = algoliaClient.initIndex(ALGOLIA_CITY_INDEX)
  return cityIndex.search(cityName || departementId).then(({hits}): CitySuggestion => {
    const bestCityById = hits.find(({cityId: id}): boolean => id === cityId)
    if (bestCityById) {
      return bestCityById
    }
    const bestCityByName = hits.find(({name}): boolean => name === cityName)
    if (bestCityByName) {
      return bestCityByName
    }
    const bestCityByDepartement = hits.find(({departementId: id}): boolean => id === departementId)
    if (bestCityByDepartement) {
      return bestCityByDepartement
    }
    return hits[0] || {}
github hummingbird-me / kitsu-mobile / src / screens / Search / SearchScreen / index.js View on Github external
executeSearch = (query, scene) => {
    const currentScene = this.scenes[scene];
    if (isEmpty(currentScene.apiKey)) { return; }

    const client = algolia(kitsuConfig.algoliaAppId, currentScene.apiKey);
    const index = client.initIndex(currentScene.indexName);
    const filters = currentScene.kind ? `kind:${currentScene.kind}` : '';
    index.search({ query, filters}, (err, content) => {
      if (!err) {
        this.setState({
          searchResults: {
            ...this.state.searchResults,
            [scene]: content.hits,
          },
        });
      }
    });
  };
  debouncedSearch = debounce(this.executeSearch, 150);
github algolia / doc-code-samples / React InstantSearch Native / getting-started / App.js View on Github external
StyleSheet,
  View,
  SafeAreaView,
  StatusBar,
  Button,
} from 'react-native';
import algoliasearch from 'algoliasearch/reactnative';
import {
  InstantSearch,
  connectRefinementList,
} from 'react-instantsearch-native';
import SearchBox from './src/SearchBox';
import InfiniteHits from './src/InfiniteHits';
import Filters from './src/Filters';

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

const styles = StyleSheet.create({
  safe: {
    flex: 1,
    backgroundColor: '#252b33',
  },
  container: {
    flex: 1,
    backgroundColor: '#FFFFFF',
  },
});

const VirtualRefinementList = connectRefinementList(() => null);
github tylermcginnis / react-native-algolia-dropdown / index.js View on Github external
constructor (props) {
    super()
    validateChildProps(props.children)
    this.client = algoliasearch(props.appID, props.apiKey)

    this.state = {
      showOverlay: false,
      results: [],
      cancelWidth: new Animated.Value(0),
      cancelOpacity: new Animated.Value(0),
      resultsHeight: new Animated.Value(0),
    }

    this.handleTextChange = this.handleTextChange.bind(this)
    this.handleSearch = this.handleSearch.bind(this)
    this.formatQuery = this.formatQuery.bind(this)
    this.handleFocus = this.handleFocus.bind(this)
    this.handleRemoveFocus = this.handleRemoveFocus.bind(this)
    this.getInputStyle = this.getInputStyle.bind(this)
  }

algoliasearch

A fully-featured and blazing-fast JavaScript API client to interact with Algolia API.

MIT
Latest version published 2 months ago

Package Health Score

92 / 100
Full package analysis