Skip to content

I'm LOST! Typing values loses focus. #4348

Answered by ebonow
zmagickap asked this question in Q&A
Discussion options

You must be logged in to vote

Greetings @zmagickap ,

The issue is how you are declaring SearchWO within WoSelector. This means that every time that WoSelector re-renders, it redeclares SearchWO and it loses the original instance. You can avoid this by simply returning the JSX of SearchWO or declaring SearchWO outside the scope of WoSelector.

This should work better for you...
Working demo: codesandbox

import React, { useState } from "react";
import Select from "react-select";

function WoSelector() {
  const [Wo, setWo] = useState("");

  const workOrders = [
    { value: "102570", label: "102570" },
    { value: "102571", label: "102571" },
    { value: "102572", label: "102572" }
  ];

  function handleOnChange(inpu…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@zmagickap
Comment options

Answer selected by zmagickap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants