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

docs(highlight): prettier and fix import #413

Merged
merged 1 commit into from
Oct 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions docgen/src/guide/Highlighting_results.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ tag is `em`, mostly for legacy reasons.
```jsx
import React from 'react';

import {InstantSearch, Hits, Highlight} from 'InstantSearch';
import { InstantSearch, Hits, Highlight } from 'react-instantsearch/dom';

const Hit = ({hit}) =>
<p>
<Highlight attributeName="description" hit={hit} tagName="mark"/>
</p>;
const Hit = ({ hit }) => (
<p>
<Highlight attributeName="description" hit={hit} tagName="mark" />
</p>
);

export default function App() {
return (
<InstantSearch
appId="latency"
apiKey="6be0576ff61c053d5f9a3225e2a90f76"
indexName="ikea">
appId="latency"
apiKey="6be0576ff61c053d5f9a3225e2a90f76"
indexName="ikea"
>
<Hits hitComponent={Hit} />
</InstantSearch>
);
Expand Down Expand Up @@ -82,7 +84,11 @@ import { InstantSearch, Hits } from 'react-instantsearch/dom';

const CustomHighlight = connectHighlight(
({ highlight, attributeName, hit, highlightProperty }) => {
const parsedHit = highlight({ attributeName, hit, highlightProperty: '_highlightResult' });
const parsedHit = highlight({
attributeName,
hit,
highlightProperty: '_highlightResult'
});
const highlightedHits = parsedHit.map(part => {
if (part.isHighlighted) return <mark>{part.value}</mark>;
return part.value;
Expand All @@ -91,17 +97,19 @@ const CustomHighlight = connectHighlight(
}
);

const Hit = ({hit}) =>
<p>
<CustomHighlight attributeName="description" hit={hit}/>
</p>;
const Hit = ({ hit }) => (
<p>
<CustomHighlight attributeName="description" hit={hit} />
</p>
);

export default function App() {
return (
<InstantSearch
appId="latency"
apiKey="6be0576ff61c053d5f9a3225e2a90f76"
indexName="ikea">
appId="latency"
apiKey="6be0576ff61c053d5f9a3225e2a90f76"
indexName="ikea"
>
<Hits hitComponent={Hit} />
</InstantSearch>
);
Expand Down