Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit 33e646c

Browse files
samoussfrancoischalifour
authored andcommitted
feat(templates): Use searchClient in React (#113)
1 parent 4a87bbe commit 33e646c

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

scripts/__snapshots__/e2e-templates.test.js.snap

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3761,6 +3761,7 @@ exports[`Templates React InstantSearch File content: src/App.css 1`] = `
37613761
37623762
exports[`Templates React InstantSearch File content: src/App.js 1`] = `
37633763
"import React, { Component } from 'react';
3764+
import algoliasearch from 'algoliasearch/lite';
37643765
import {
37653766
InstantSearch,
37663767
Hits,
@@ -3772,6 +3773,11 @@ import {
37723773
import PropTypes from 'prop-types';
37733774
import './App.css';
37743775
3776+
const searchClient = algoliasearch(
3777+
'appId',
3778+
'apiKey'
3779+
);
3780+
37753781
class App extends Component {
37763782
render() {
37773783
return (
@@ -3789,11 +3795,7 @@ class App extends Component {
37893795
</header>
37903796
37913797
<div className=\\"container\\">
3792-
<InstantSearch
3793-
appId=\\"appId\\"
3794-
apiKey=\\"apiKey\\"
3795-
indexName=\\"indexName\\"
3796-
>
3798+
<InstantSearch searchClient={searchClient} indexName=\\"indexName\\">
37973799
<div className=\\"search-panel\\">
37983800
<div className=\\"search-panel__filters\\">
37993801
<RefinementList attribute=\\"facet1\\" />

src/templates/React InstantSearch/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint:fix": "npm run lint -- --fix"
1010
},
1111
"dependencies": {
12+
"algoliasearch": "3.29.0",
1213
"react": "16.4.1",
1314
"react-dom": "16.4.1",
1415
"react-instantsearch-dom": "{{libraryVersion}}",

src/templates/React InstantSearch/src/App.js.hbs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component } from 'react';
2+
import algoliasearch from 'algoliasearch/lite';
23
import {
34
InstantSearch,
45
Hits,
@@ -14,6 +15,11 @@ import {
1415
import PropTypes from 'prop-types';
1516
import './App.css';
1617

18+
const searchClient = algoliasearch(
19+
'{{appId}}',
20+
'{{apiKey}}'
21+
);
22+
1723
class App extends Component {
1824
render() {
1925
return (
@@ -31,11 +37,7 @@ class App extends Component {
3137
</header>
3238

3339
<div className="container">
34-
<InstantSearch
35-
appId="{{appId}}"
36-
apiKey="{{apiKey}}"
37-
indexName="{{indexName}}"
38-
>
40+
<InstantSearch searchClient={searchClient} indexName="{{indexName}}">
3941
<div className="search-panel">
4042
{{#if attributesForFaceting}}
4143
<div className="search-panel__filters">

0 commit comments

Comments
 (0)