React-instantsearch: MultiRange Label Object

Created on 23 May 2017  ยท  5Comments  ยท  Source: algolia/react-instantsearch

Question

Should MultiRange accept Object typed variables passed to it's label property to support JSX? Currently it throws a warning as it only expects type String.

โ” Question

All 5 comments

Hi @flouc001

That's a choice we made, translations such as labels are only accepting strings.

If you wish to have a complete different render then you should use the connectMultiRange connector.

MultiRange also accepts a transformItems props if you need to add information without touching the DOM.

What are you trying to achieve in term of display?

Hi @mthuret

That's unfortunate. The render is completely fine and gives me the desired look and feel however I get a PropType warning telling me I should be using a String when I am in fact passing a JSX Object.

It's just a warning so it can be ignored however it would be nice to add objects to the acceptable PropTypes. However like you say the decision was made.

Thanks for your reply!

I'm curious, can you share the look and feel of what you're doing?

So I have created a React Component called Icon which essentially takes properties and renders a FontAwesome formatted <i> element. I am replicating the StarRating widget from just using the MultiRange widget instead. To make it look nice I use FontAwesome stars for the label property. Here's an example:

<MultiRange attributeName="rank" 
    items={[
        {start:0, label: (<span><Icon icon="star" /><span>{" & Up"}</span></span>)}
    ]}
/>

Obviously this example isn't complete but it gives an idea.

That's good to know. I'm closing this for now.

I'll let you know if there's any evolution about this subject.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markmiller21 picture markmiller21  ยท  3Comments

vinhlh picture vinhlh  ยท  5Comments

flouc001 picture flouc001  ยท  5Comments

noclat picture noclat  ยท  3Comments

flouc001 picture flouc001  ยท  4Comments