Integration within React apps
See original GitHub issueFollow-up from #831
@vvo thanks! Not much feedback for the moment as the project is still at a very early stage and as i’m just discovering the lib.
I was wondering, though, if there might be a more straightforward integration within a React app. Excuse-me if it’s already the case. I was thinking about an api like, for example :
import React, { Component } from 'react'
import { InstantSearch, SearchBox, Hits } from 'instantsearch.js'
class MySearchComponent extends Component {
render() {
return (
<InstantSearch
appId={ appId }
apiKey={ apiKey }
indexName={ indexName }
>
<SearchBox
placeholder={ 'Custom placeholder' }
/>
<Hits
hitsPerPage={ 6 }
renderHit={ hit => <MyItemComponent item={ hit } /> }
/>
</InstantSearch>
);
}
}
Some of the benefits i see in such an approach would be :
- the whole tree gets re-rendered when the parent component’s
props
orstate
are updated - the
context
does not get lost : useful with libs relying on it such asreact-router
- we get server-side rendering for free
- no risk of conflicts between different React versions
- maybe modularize dependencies to avoid bundling
hogan
or other libs that react apps won’t use
Would that be a big refactoring ? I understand the lib is not mainly targeting React apps, but as it is all React, it doesn’t seem too difficult. The reference to the search helper could be passed to the widgets via context
Sorry if all that’s already possible or off-topic.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Integrating with Other Libraries - React
React can be used in any web application. It can be embedded in other applications and, with a little care, other applications can...
Read more >ReactJS Integrating with Other Libraries - GeeksforGeeks
Step 1: Create a React application using the following command. · Step 2: After creating your project folder i.e. foldername, move to it...
Read more >React Integration Testing with React-testing-library - Toptal
Integration tests can help preserve peace of mind while making changes to a React app, as they ensure that the composition of components...
Read more >Step-by-Step Guide to Integrate Mobile App with React Native
Step 1: Prerequisite · Step 2: Restructuring the existing project · Step 3: Integrating React Native into the project · Step 4: Adding...
Read more >How to install for React applications manual - Semrush
SplitSignal integrates via JavaScript code snippet and applies test changes directly to the DOM elements. To correctly interact with React-based single-page ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We are going to create reusable React components with #920
Can you send me an email to vincent@algolia.com to further continue this discussion? We have plans to make instantsearch.js more React friendly, gradually