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.

onRemove handler not working in version with custom valueComponent

See original GitHub issue

In version ^1.0.0-rc.10 this is not working. Select component:

<Select.Async
                        name="signal-filter"
                        className={styles.selectSignals}
                        placeholder={signalsPlaceholder}
                        searchPromptText="Type to search (at least 2 characters)"
                        value={values}
                        valueComponent={TrendsSelectValue}
                        loadOptions={this.getSignalsOptions}
                        onChange={this.onChangeTicketsSignals}
                        isLoading={this.props.isLoadingSignals}
                        disabled={isLoadingSignals || isLoadingOntology || isFilteringTickets || isLoadingTickets || isLoadingMonthTickets}
                        delimiter={getReactSelectDelimiter()}
                        simpleValue
                        multi
                    />

Value component:

import React, {Component} from 'react';
import classNames from 'classnames';
import {trendSearchSeparators} from '../../../../utils/constants';
import styles from './TrendsSelectValue.less';

export default class TrendsSelectValue extends Component {
    render() {
        const isSeparator = this.props.value.label.indexOf(`__${trendSearchSeparators.and}__`) !== -1;
        if (isSeparator) {
            const separatorClass = classNames({
                'Select-value': true,
                [styles.separator]: true
            });
            return <div className={separatorClass}>
                <span className="Select-value-label">{trendSearchSeparators.and.toUpperCase()}</span>
            </div>
        }
        return <div className="Select-value">
            <span className="Select-value-icon" onClick={this.props.onRemove}>×</span>
            <span className="Select-value-label">{this.props.value.label}</span>
        </div>
    }
}

In previous version all worked fine, but in 1.0.0-rc.10 onChange handler works after onRemove , but with the same value, without removing

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
tonisostratcommented, Jan 3, 2018

You need to pass the value property from the props to the onRemove function.

Inline it should look like this:

<Select
  //other props
  valueComponent={option => {
    return (
      <div>{option.value.label}<button onClick={() => option.onRemove(option.value)}>X</button></div>
    );
  }}
0reactions
bladeycommented, May 28, 2020

Hello -

In an effort to sustain the react-select project going forward, we’re closing old issues.

We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our efforts towards the current major version.

If you aren’t using the latest version of react-select please consider upgrading to see if it resolves any issues you’re having.

However, if you feel this issue is still relevant and you’d like us to review it - please leave a comment and we’ll do our best to get back to you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - Property 'onRemove' does not exist on type
Please close this task, problem is solved in another task, i attach link below. Delete an element by key from Array.
Read more >
Developer Guide: Components - AngularJS: API
In AngularJS, a Component is a special kind of directive that uses a simpler configuration which is suitable for a component-based application structure....
Read more >
React Hooks - Understanding Component Re-renders - Medium
Here is the modified version of the onRemove handler without a dependency on the watchlist array. The inner function gets the current watchlist ......
Read more >
MultiSelect - Mantine
MultiSelect support two different data formats: An array of strings – use when you do not need to customize item component or display...
Read more >
Components - React Select
The problem here isn't just about performance — remounting a component causes ... Control> )}} /> ) // Good: Custom component declared outside...
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