How to configure Fuse.js search result to match a single word?

313 Views Asked by At

The field with only one word is ignored in the search result.

 const [input, setInput] = useState("");
  const data = [
    { name: "LOL" },
    { name: "PUBG" },
    { name: "PlayerUnknown's Battlegrounds" },
    { name: "League of legends" },
  ];
  const handleOnChange = (e) => {
    e.preventDefault();
    setInput(e.target.value);
  };
  const fuse = new Fuse(data, {
    keys: ["name"],
    shouldSort: true
  });
  const results = fuse.search(!input ? " " : input);

Source code and search result

How to solve it? Thanks in advance.

0

There are 0 best solutions below