Skip to content

Commit

Permalink
feat(templates): Use searchClient in React (algolia/create-instants…
Browse files Browse the repository at this point in the history
  • Loading branch information
samouss authored and francoischalifour committed Jul 9, 2018
1 parent 5ed04b3 commit 1b0ecab
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
12 changes: 7 additions & 5 deletions scripts/__snapshots__/e2e-templates.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3761,6 +3761,7 @@ exports[`Templates React InstantSearch File content: src/App.css 1`] = `
exports[`Templates React InstantSearch File content: src/App.js 1`] = `
"import React, { Component } from 'react';
import algoliasearch from 'algoliasearch/lite';
import {
InstantSearch,
Hits,
Expand All @@ -3772,6 +3773,11 @@ import {
import PropTypes from 'prop-types';
import './App.css';
const searchClient = algoliasearch(
'appId',
'apiKey'
);
class App extends Component {
render() {
return (
Expand All @@ -3789,11 +3795,7 @@ class App extends Component {
</header>
<div className=\\"container\\">
<InstantSearch
appId=\\"appId\\"
apiKey=\\"apiKey\\"
indexName=\\"indexName\\"
>
<InstantSearch searchClient={searchClient} indexName=\\"indexName\\">
<div className=\\"search-panel\\">
<div className=\\"search-panel__filters\\">
<RefinementList attribute=\\"facet1\\" />
Expand Down
1 change: 1 addition & 0 deletions src/templates/React InstantSearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint:fix": "npm run lint -- --fix"
},
"dependencies": {
"algoliasearch": "3.29.0",
"react": "16.4.1",
"react-dom": "16.4.1",
"react-instantsearch-dom": "{{libraryVersion}}",
Expand Down
12 changes: 7 additions & 5 deletions src/templates/React InstantSearch/src/App.js.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component } from 'react';
import algoliasearch from 'algoliasearch/lite';
import {
InstantSearch,
Hits,
Expand All @@ -14,6 +15,11 @@ import {
import PropTypes from 'prop-types';
import './App.css';

const searchClient = algoliasearch(
'{{appId}}',
'{{apiKey}}'
);

class App extends Component {
render() {
return (
Expand All @@ -31,11 +37,7 @@ class App extends Component {
</header>

<div className="container">
<InstantSearch
appId="{{appId}}"
apiKey="{{apiKey}}"
indexName="{{indexName}}"
>
<InstantSearch searchClient={searchClient} indexName="{{indexName}}">
<div className="search-panel">
{{#if attributesForFaceting}}
<div className="search-panel__filters">
Expand Down

0 comments on commit 1b0ecab

Please sign in to comment.