title: Filtering users with filter function - React with next.js and typescript
body: <p>i'm developing my fronted app with next.js and typescript, and i'm trying to filter an array in order to show only the users that you are looking for, like a search bar, but, it returns me always undefined.</p>
  <p>Let me show you a litle bit of my code.</p>
  <p>Firts of all, the function i made <strong>filteredUsers</strong></p>
  <pre><code>const [searchBar, setSearchBar] = useState&lt;boolean&gt;(false);
  
    const [results, setResults] = useState&lt;string&gt;(&quot;&quot;);
  
    // Searchbar users
  
    if (typeof window !== &quot;undefined&quot;) {
      const userId: dataObject = JSON.parse(localStorage.getItem(&quot;Auth&quot;));
      var { data }: multipleUsers = useSWR(
        &quot;http://localhost:5000/api/user/allU/&quot; + userId.user.id
      );
    }
  
    const filteredUsers = useMemo(() =&gt; {
      data !== undefined &amp;&amp;
        data.filter(user =&gt; {
          return user.name.toLowerCase().includes(results.toLowerCase());
        });
    }, [results]);
  
    console.log(filteredUsers);
    console.log(results);
  </code></pre>
  <p>Now, the interfaces to understand what type of data i'm expecting</p>
  <pre><code>// User representation
  
  type user = {
    id?: string;
    name?: string;
    email?: string;
    password?: string;
    friends?: [];
    banner?: string;
    perfil?: string;
  };
  
  export interface IuserData {
    data: user;
  }
  
  export type multipleUsers = { data: user[] };
  
  </code></pre>
  <p>Now, let me show you what the console.log() is showing for me</p>
  <p><a href="https://i.stack.imgur.com/NG6jZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NG6jZ.png" alt="enter image description here" /></a></p>
  <p><strong>First value</strong> is the data i'm receving.</p>
  <p><strong>The second one</strong> is the result of my function, which is undefined always</p>
  <p><strong>Third one</strong> is the value of my input</p>
  <p>What can i do in order to get the results i'm looking for based on the value of my input ?</p>
  <p>Thanks for your time !</p>