#what is wrong with the onchange event?

1 messages · Page 1 of 1 (latest)

torn tide
#

i can give you on change part of the code since it is way big code

#
                    <div className="mt-2">
                      <select
                        placeholder="Please Enter your State"
                        onChange={(e) => {
                          console.log(e);
                          getStateCode(e.target.value);
                        }}
                        name="state"
                        className="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
                        {...register("state")}
                      >
                        {states?.map((state) => {
                          return <option>{state.name}</option>;
                        })}

                      </select>
                    </div>
#

the console.log is not printing anything on the console

#
 const getStateCode = (selectedState) => {
    console.log(selectedState);
    states.map((state) => {
      if (state.name === selectedState) {
        setStateCode(state.isoCode);
      }
    });
  };
#

In-short, states array is coming from an API and I'm validating the API name and user selected name.
If you still can't understand my problem it's ok I can provide more details, code and screenshots.

#

thank you for looking out in my problem in advance.

torn tide
#

help?!