
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
react-algoliasearch-helper-vl
Advanced tools
React `` and `connect()(WrappedComponent)` for algoliasearch-helper
--- NOTE FROM MAINTAINERS --- (Sept 2016) We are working on react-instantsearch, it's already working. Ping me on twitter: https://twitter.com/vvoyer if you want to be an alpha tester
react-instantsearch is a react specific UI library for Algolia, much easier than react-algoliasearch-helper --- / NOTE FROM MAINTAINERS ---
React <Provider>
and connect(WrappedComponent)
for algoliasearch-helper.
Its goal is to make building React applications with Algolia easier by allowing easy access to the algoliasearch-helper.
Table of Contents
npm install react-algoliasearch-helper --save
SearchBox.js
import React from 'react';
import {connect} from 'react-algoliasearch-helper';
export default connect()(
({helper}) =>
<input
placeholder="Search here"
autoFocus
onChange={e => helper.setQuery(e.target.value).search()}
/>
);
Hits.js
import React, {PropTypes} from 'react';
import {connect} from 'react-algoliasearch-helper';
const Results = ({results}) => {
if (!results) return <div/>;
return <div>{results.hits.map(hit => <div key={hit.objectID}>{hit.Name}</div>)}</div>;
};
Results.propTypes = {
results: PropTypes.object
};
export default connect(
state => ({results: state.searchResults})
)(Results);
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import algoliasearch from 'algoliasearch';
import algoliasearchHelper from 'algoliasearch-helper';
import {Provider} from 'react-algoliasearch-helper';
import SearchBox from './components/SearchBox.js';
import Hits from './components/Hits.js';
const client = algoliasearch('latency', 'ffc36feb6e9df06e1c3c4549b5af2b31');
const helper = algoliasearchHelper(client, 'starbucks');
const App = () =>
<Provider helper={helper}>
<div>
<SearchBox/>
<Hits/>
</div>
</Provider>;
ReactDOM.render(<App/>, document.querySelector('#root'));
<Provider helper>
Makes the Algolia Search helper
available to the connect()
calls in the component hierarchy below. You can’t use connect() without wrapping your root component in .
helper
(algoliasearch-helper-js):children
(ReactElement) The root of your component hierarchy.ReactDOM.render(
<Provider helper={helper}>
<MyRootComponent />
</Provider>,
rootEl
)
connect([mapStateToProps])(WrappedComponent)
Connects a React component to the helper.
[mapStateToProps(state, ownProps): stateProps]
(function): if specified, the component will subscribe to helper events (change
, search
, result
, error
). Allowing you to compute props for your wrapper component based on the search state.Every function passed to mapStateToProps
argument of connect
will be given an search state object with those properties:
searching
(boolean): true
when a search request is pending, false otherwisesearchParameters
(object): helper's SearchParameterssearchResults
(object): helper's SearchResultssearchResultsSearchParameters
(object): SearchParameters that yielded the current SearchResultssearchError
(Error): When the search failsconnect([mapStateToProps])(WrappedComponent)
.connect
as in export default connect()(WrappedComponent)
.Forward helper
to the RefinementList
component:
export default connect()(RefinementList)
Receive results
in the Hits
component:
export default connect(
state =>
({
results: state.searchResults
})
)(Hits) // Hits component will receive a `results` property everytime new results are available
Tests are written with Jest.
npm test
npm run test:watch
npm run lint
npm start
npm run release
FAQs
React `` and `connect()(WrappedComponent)` for algoliasearch-helper
The npm package react-algoliasearch-helper-vl receives a total of 0 weekly downloads. As such, react-algoliasearch-helper-vl popularity was classified as not popular.
We found that react-algoliasearch-helper-vl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.