List is not reloaded after inserting data into the database

Hello!

I’m using useQuery to access a list from a realm schema.

The problem in question is that, after inserting an item into the list, apparently the realm db is not reporting the updated list to me.

Has anyone ever experienced this?

This is the current component where I list the customers.

Thank you very much in advance!

import { useQuery } from '@realm/react';

const clients = useQuery(ClientSchema);

<S.ClientsList
          data={clients}
          keyExtractor={(client) => `${client._id}`}
          ListEmptyComponent={
            <EmptyList isLoading={false} text="Nenhum cliente encontrado" />
          }
          renderItem={({ item: client }) => (
            <ClientCard
              client={client}
              onChange={(client) => {
                console.log({ client });
                // setIsShowClientModal(false);
              }}
            />
          )}
        />

ClientsList is a FlatList.

The problem is that I was using realm.close() in the promise on the screen where I register customers.

For some reason, the log did not show any errors in the previously mentioned flow. The RN only showed a connection problem when I tried to use eventListener on the listing screen.

So the solution was just not to call close() on the promise that registers.