Testing React Select component

This is a recurrent question. I’m sharing my own code with 100% passing tests which cover 100% of my source code. My component looks like this MySelectComponent({ options, onChange }) { return <div data-testid=”my-select-component”> <Select className=”basic-single” classNamePrefix=”select” name=”myOptions” placeholder=”Select an option” options={options} onChange={e => onChange(e)} /> </div>; } The reason I’m adding a wrapper on … Read more

Changing height of react-select component

Spending hours, I end up with this to get exact 30px height of react select with border 1px: const customStyles = { control: (provided, state) => ({ …provided, background: ‘#fff’, borderColor: ‘#9e9e9e’, minHeight: ’30px’, height: ’30px’, boxShadow: state.isFocused ? null : null, }), valueContainer: (provided, state) => ({ …provided, height: ’30px’, padding: ‘0 6px’ }), … Read more

react-select: Is there a way to remove the button on the right that expand the list, at least in async mode?

We can remove the dropdown indicator by including DropdownIndicator: () => null in components property. Update:As @shlgug and @nickornotto suggested remove separator by including IndicatorSeparator:() => null <Select components={{ DropdownIndicator:() => null, IndicatorSeparator:() => null }} />

How to style react-select options

react select v2 (update) This new version introduces a new styles-api and some other major changes. Custom Styles Style individual components with custom css using the styles prop. const colourStyles = { control: styles => ({ …styles, backgroundColor: ‘white’ }), option: (styles, { data, isDisabled, isFocused, isSelected }) => { const color = chroma(data.color); return … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)