Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

dataHandler is still called twice #109

Open
nateswork1818 opened this issue Oct 6, 2023 · 0 comments
Open

dataHandler is still called twice #109

nateswork1818 opened this issue Oct 6, 2023 · 0 comments

Comments

@nateswork1818
Copy link

nateswork1818 commented Oct 6, 2023

Still have a problem like in this issue.

I have installed v0.8.1
When I try to send data to the database inside the dataHandler function, all my functions run twice, leading to incorrect results:
console log:
image

My code:

<Importer
          dataHandler={async (rows) => {
            console.log(
              "🚀 ~ file: AddFromCsvTab.tsx:88 ~ dataHandler={ ~ rows:",
              rows
            );
            const data = await createList.mutateAsync({
              orgId: curUser?.current_org_id!,
              addedByUserId: curUser?.cur_user_id!,
              listName: newListName!,
            });

            rows.forEach((row) => {
              addContactToNewList.mutate({
                addedByUserId: curUser?.user_id!,
                orgId: curUser?.current_org_id!,
                listId: data.listId,
                ...(row as CsvContactInfo),
              });
            });
          }}
          defaultNoHeader={false} // optional, keeps "data has headers" checkbox off by default
          restartable={true} // optional, lets user choose to upload another file when import is complete
          locale={enUS}
          skipEmptyLines={true}
        >
          <ImporterField name="firstName" label="First Name" />
          <ImporterField name="lastName" label="Last Name" />
          <ImporterField name="email" label="Email" />
          <ImporterField name="notes" label="Info" />
        </Importer>

My CSV file: List.csv

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant