Skip to content

Commit 6c479e0

Browse files
bors[bot]bidoubiwa
andauthored
Merge #395
395: Change react playground to function component r=bidoubiwa a=bidoubiwa We mixed two component styles. This PR make our playground code more consistent Co-authored-by: Charlotte Vermandel <[email protected]>
2 parents 4387271 + 6f78a5c commit 6c479e0

File tree

1 file changed

+43
-52
lines changed

1 file changed

+43
-52
lines changed

playgrounds/react/src/App.js

Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'instantsearch.css/themes/algolia-min.css'
2-
import React, { Component } from 'react'
2+
import React from 'react'
33
import {
44
InstantSearch,
55
InfiniteHits,
@@ -22,59 +22,50 @@ const searchClient = instantMeiliSearch(
2222
}
2323
)
2424

25-
class App extends Component {
26-
render() {
27-
return (
28-
<div className="ais-InstantSearch">
29-
<h1>MeiliSearch + React InstantSearch</h1>
30-
<h2>
31-
Search in Steam video games{' '}
32-
<span role="img" aria-label="emoji">
33-
🎮
34-
</span>
35-
</h2>
36-
<p>
37-
This is not the official Steam dataset but only for demo purpose.
38-
Enjoy searching with MeiliSearch!
39-
</p>
40-
<InstantSearch
41-
indexName="steam-video-games"
42-
searchClient={searchClient}
43-
>
44-
<Stats />
45-
<div className="left-panel">
46-
<ClearRefinements />
47-
<h2>Genres</h2>
48-
<RefinementList attribute="genres" />
49-
<h2>Players</h2>
50-
<RefinementList attribute="players" />
51-
<h2>Platforms</h2>
52-
<RefinementList attribute="platforms" />
53-
<h2>Misc</h2>
54-
<RefinementList attribute="misc" />
55-
<Configure hitsPerPage={6} />
56-
</div>
57-
<div className="right-panel">
58-
<SearchBox />
59-
<InfiniteHits hitComponent={Hit} />
60-
</div>
61-
</InstantSearch>
25+
const App = () => (
26+
<div className="ais-InstantSearch">
27+
<h1>MeiliSearch + React InstantSearch</h1>
28+
<h2>
29+
Search in Steam video games{' '}
30+
<span role="img" aria-label="emoji">
31+
🎮
32+
</span>
33+
</h2>
34+
<p>
35+
This is not the official Steam dataset but only for demo purpose. Enjoy
36+
searching with MeiliSearch!
37+
</p>
38+
<InstantSearch indexName="steam-video-games" searchClient={searchClient}>
39+
<Stats />
40+
<div className="left-panel">
41+
<ClearRefinements />
42+
<h2>Genres</h2>
43+
<RefinementList attribute="genres" />
44+
<h2>Players</h2>
45+
<RefinementList attribute="players" />
46+
<h2>Platforms</h2>
47+
<RefinementList attribute="platforms" />
48+
<h2>Misc</h2>
49+
<RefinementList attribute="misc" />
50+
<Configure hitsPerPage={6} />
6251
</div>
63-
)
64-
}
65-
}
66-
67-
function Hit(props) {
68-
return (
69-
<div key={props.hit.id}>
70-
<div className="hit-name">
71-
<Highlight attribute="name" hit={props.hit} />
52+
<div className="right-panel">
53+
<SearchBox />
54+
<InfiniteHits hitComponent={Hit} />
7255
</div>
73-
<img src={props.hit.image} align="left" alt={props.hit.name} />
74-
<div className="hit-info">price: {props.hit.price}</div>
75-
<div className="hit-info">release date: {props.hit.releaseDate}</div>
56+
</InstantSearch>
57+
</div>
58+
)
59+
60+
const Hit = ({ hit }) => (
61+
<div key={hit.id}>
62+
<div className="hit-name">
63+
<Highlight attribute="name" hit={hit} />
7664
</div>
77-
)
78-
}
65+
<img src={hit.image} align="left" alt={hit.name} />
66+
<div className="hit-info">price: {hit.price}</div>
67+
<div className="hit-info">release date: {hit.releaseDate}</div>
68+
</div>
69+
)
7970

8071
export default App

0 commit comments

Comments
 (0)