File size: 962 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import React from 'react';
import PropTypes from 'prop-types';
import Mention from 'antd/lib/mention';
import algoliasearch from 'algoliasearch/lite';
import { InstantSearch, connectAutoComplete } from 'react-instantsearch-dom';
import 'antd/lib/mention/style/css';
const AsyncMention = ({ hits, refine }) => (
<Mention
style={{ width: 500, height: 100 }}
prefix="@"
notFoundContent={'No suggestion'}
placeholder="give someone an @-mention here"
suggestions={hits.map((hit) => hit.name)}
onSearchChange={(query) => refine(query)}
/>
);
AsyncMention.propTypes = {
hits: PropTypes.array,
refine: PropTypes.func,
};
const ConnectedAsyncMention = connectAutoComplete(AsyncMention);
const searchClient = algoliasearch(
'latency',
'6be0576ff61c053d5f9a3225e2a90f76'
);
const App = () => (
<InstantSearch searchClient={searchClient} indexName="actors">
<ConnectedAsyncMention />
</InstantSearch>
);
export default App;
|