Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
I am trying to Reast React-Select's AsyncSelect from a parent component (https://react-select.com/home)

I am trying to reset AsyncReact (https://react-select.com/home) from a parent component (Hooks) but I cant seem to get it to work. Any help much appreciated.

I can reset it from within the component by setting the state to an empty array but I cant seem to reset it from outside.

Parent Component

const MessengerMessagesTwo = ({ props }) => {
    
   const orgSearchRef = useRef(null);

   
   

 const handleClearOrgSearch = () => {
        orgSearchRef.current.clearValue();
    }

 return <div>

 <button onClick={() => handleClearOrgSearch()}>clear</button>

 <MessengerMessagesTwoOrgSearch ref={orgSearchRef} />
</div>
})

Child Component




const MessengerMessagesTwoOrgSearch = forwardRef(({props}, ref) => {

    const [inputValue, setInputValue] = useState([]);

    useEffect(() => {
        setInputValue([]);

        return () => {
            setInputValue([]); // reset orgs selected
            handleOrgSelectedCallback([]);
        }
    }, [])

    return <div>
        <AsyncSelect
            isClearable
            defaultOptions
            placeholder="Search Orgs"
            loadOptions={loadOptions}
            onInputChange={handleInputChange}
            onChange={handleChange}
            isMulti
            noOptionsMessage={i => "Search..."}
            ref={ref}
        />
    </div>
})


const mapStateToProps = (state) => {
    return {
    };
};

const mapDispatchToProps = (dispatch) => {
    return {
        
    };
};

export default connect(mapStateToProps, mapDispatchToProps, null, {forwardRef: true})(MessengerMessagesTwoOrgSearch);

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Seems to be working now. Did not change anything, and I am very confused

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda