question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integration within React apps

See original GitHub issue

Follow-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 or state are updated
  • the context does not get lost : useful with libs relying on it such as react-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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
vvocommented, Jun 10, 2016

We are going to create reusable React components with #920

0reactions
vvocommented, Feb 16, 2016

Yes, I’d be very pleased too 😃 I’m Paris too and can make myself available this week when you want!

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found