Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!