spotty-amberS
Refine3y ago
5 replies
spotty-amber

Default query result duplicates the options of select options.

Previously I have asked a question regarding how to create a custom option in select input ask-any-question-archivedHow to customize useSelect hooks optionLabel with multiple value? and implemented a solution provided by @Omer. But now I have an issue with that process as my default query populates the options value with other options which results the same value being shown twice. For example I have a useSelect hook to get a data as below:
   const { queryResult, defaultValueQueryResult } = useSelect<ISeatlayout>({
        resource: "buslayouts",
        optionLabel: "structure",
        defaultValue: record?.bus_layouts || [],

        pagination: {
            mode: "server",
            pageSize: 100
        }
  });

    const allLayoutOptions = [
        ...(queryResult?.data?.data || []),
        ...(defaultValueQueryResult?.data?.data || [])
    ];


Here in my allLayoutOptions the data will be populate twice as I get the value from queryResult and the same value from the defaultValueQueryResult, is there a better solution you can suggest me? Or else I am thinking of a solution as to filter out the duplicated value from allLayoutOptions. Is this the solution that I should move on with?
Was this page helpful?