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.

Standalone React components

See original GitHub issue

— 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 — / NOTE FROM MAINTAINERS —

instantsearch.js is currently a collection of smart JavaScript widgets rendering dumb React components.

  • smart as “I know how to manipulate the helper to refine this brand list”
  • dumb as “Give me a data list and a click function and I will display them”

This worked well for a lot of people but not for people already using React (or Angular, React Native, ractive, vuejs or any framework with his own concepts like state, scope, JSX …).

To progressively solve this situation, we should first try to build the famous instant search demo with React only and see how it goes.

It would be a first POC at making instantsearch.js React friendly.

To avoid making instantsearch.js React friendly ONLY (and miss Angular or others), we should be careful about how we organize code. For instance, the function knowing how to refine a facet should be extracted and reused inside the component.

The ultimate goal of this POC is to be able to (not actual API, only for issue):

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>
    );
  }
}

While still being able to do:

// From react
import { InstantSearch, SearchBox, Hits, Pagination } from 'instantsearch.js/react';
// From another environment
import instantsearch from 'instantsearch.js';

Relevant discussion: https://github.com/algolia/instantsearch.js/issues/833

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vvocommented, Apr 26, 2016

Hi @eyeinsky no news nor estimate for the moment we are trying hard to make this happen of course we want to allow our React users to easily start with Algolia.

If you have a specific React + Algolia question in the meantime feel free to drop it here.

1reaction
jrasanencommented, Apr 6, 2016

👍

I bumped into this issue too today.

Thinking of either writing my own components in React using the JS api only and not using instantsearch.js. Or use this & kind of awkwardly append widget templates as strings inside a component.

Probably gonna do the latter and keep watching this thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Integrate Stand-Alone React Components on a Static ...
We will get all roots by querying the DOM for a data-react-component attribute. Then we loop over each root, we get the component...
Read more >
Add React to a Website
In this section, we will show how to add a React component to an existing HTML page. You can follow along with your...
Read more >
Standalone React Component with Webpack - Stack Overflow
Standalone React Component with Webpack · Include React/ReactDOM from a cdn somewhere on an html page. · Include my component js file (we'll...
Read more >
Standalone React.js basic example - Tutorialspoint
Below script is used to create components and perform actions on it. React uses a special syntax of JavaScript called as jsx which...
Read more >
How to Create and Publish a React Component Library
This tutorial will take you through the process of creating and publishing your own custom React component library and hosting it on Github....
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