I want to display the details of what's user clicks in the ResultCard.
I want to replace the divs contents (currently displayed results) with rendered html based on the result found in my elastic search cluster(res) when user click the url in the resultcard.
I tried adding onclick properties but nothing happens. Reactivesearch documentation don't list this attribute.
Of course, I could pass argument in the url properties of ResultCard and redirect user to another page but page would be reloaded completely (with the menus defined in index.js and the footer)
I think creating parent component with state mirroring the currently displayed children component in the div is the way to go.
But, how to run a javascript for setting the state when user click in the resultcard?
import React, { Component } from 'react';
import { ReactiveBase, CategorySearch, SingleRange, ResultCard } from '@appbaseio/reactivesearch';
class App extends Component {
render() {
return (
<ReactiveBase
app="artists"
url="https://admin:xxxxxxx@node1.searchevolution.com:9200"
type="_doc">
<div style={{ display: "flex", "flexDirection": "row" }}>
<div style={{ display: "flex", "flexDirection": "column", "width": "40%" }}>
<CategorySearch
componentId="searchbox"
dataField="nom"
categoryField="occupations.keyword"
type="artists"
placeholder="Search for Artists, Painter, Sculptor, Photographs"
style={{
padding: "5px",
"marginTop": "10px"
}}
/>
</div>
<ResultCard
componentId="result"
dataField="nom"
title="Results"
from={0}
size={6}
pagination={true}
onclick="alert('Message à afficher');"
react={{
and: ["searchbox"]
}}
onData={(res) => {
return {
image: "data:image/png;base64,iVBORw0KGgoA",
title: res.occupations,
description: res.nom,
url: "/details/" + res
}
}}
style={{
"width": "60%",
"textAlign": "center"
}}
/>
</div>
</ReactiveBase>
);
}
}
export default App;
Expected result is to change the div content with the rendered html from another component (not still coded).