• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

114
Views
Why this select tag not work right in react?

Code :

const Home = () => {
const location = useLocation();

const [lang, setLang] = useState((location.state === undefined)?"KorService":location.state.lang);


const tmp = (lang === "KorService")
    ? [//Kor Ver]
    : [//Eng Ver];

 ...

const selectLang = (e) => {
    setLang(e.target.value)
}
 ...

return (
    <div>
        <div className="header">
            <h1>{tmp[0]}</h1>
            <React.Fragment>
                <button className="lang" onClick={openModal}>Aa</button>
                <Modal open={modalOpen} close={closeModal} header={tmp[1]}>
                    <select className="langoption" onChange={selectLang}>
                        <option value="KorService">한국어</option>
                        <option value="EngService">English</option>
                    </select>
                </Modal>
            </React.Fragment>
        </div>
       ...
);

};

Result :

  • Opened Modal and clicked English option : Worked Well
  • When selecting the English option and selecting the Korea option with the modal window open : Worked Well
  • When lang is English, open modal clicked Korea : Not Worked

Want :

  • When user clicked any option, it operate immediately. I want to resolve this problem to selected Korea option well
almost 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error