question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selecting an item in ReferenceArrayInput does get

See original GitHub issue

What you were expecting:

No GET request

What happened instead:

A GET request

Steps to reproduce:

I have a relatively simple form:

import * as React from 'react';
import { Create, SimpleForm, TextInput, ReferenceArrayInput, SelectArrayInput } from 'react-admin';

const resourceSort = { field: 'resource', direction: 'asc' };

export const RoleCreate = (props: any) => (
  <Create {...props}>
    <SimpleForm>
      <TextInput source="name" />
      <ReferenceArrayInput source="permissions" reference="permissions" sort={resourceSort}>
        <SelectArrayInput optionText="action" />
      </ReferenceArrayInput>
    </SimpleForm>
  </Create>
);

After selecting an item in the dropdown a GET request is performed to:

Request URL: http://localhost:5201/api/permissions?id=69437072-89a2-496c-ade8-3970e7cd0841

I see no reason for this since we already have a list.

Related code:

In steps to reproduce.

Other information:

Environment

  • React-admin version: 4.0.0-rc.0
  • React version: 17.0.2
  • Browser: Chrome

Additional

Bonus question: I also notice that <Edit /> sends both the ids and the objects. Is this on purpose? Can I disable one or the other? See screenshot for what I mean. This is after updating a permission id.

image

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:17 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
slax57commented, May 16, 2022

@slax57 Any updates from RA on this issue? It’s one of the things keeping our team from migrating to 4.0 since our larger forms with many ReferenceInputs get bogged down making unnecessary calls, and performance grinds to a halt.

Hi! We will try to include an improvement for this in the next minor release (4.1.0), but I can’t guarantee it, since the fix will probably not be trivial and require some time and thinking through to deal with the underlying react-query behaviour.

2reactions
RWOverdijkcommented, May 10, 2022

@ZachSelindh I’d assume that if there were updates they’d be added here.

Another option is to try and fix it yourself. It sounds pretty important to you, so it’s worth spending time on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The ReferenceArrayInput Component - React-admin - Marmelab
Use <ReferenceArrayInput> to edit an array of reference values, i.e. to let users choose a list of values (usually foreign keys) from another...
Read more >
Is there any way to show pre-selected items in the react ...
When clicked the ReferenceArrayInput -> SelectArrayInput component on the ui, it does show all the record-related items (coming from client ...
Read more >
useSelect | Downshift
A custom select element can be created with HTML elements such as: label, ul, li and button. Using other HTML elements to create...
Read more >
marmelab - Bountysource
sanitizeEmptyValues will insert null value in object when removing an array item ... when there is more than one item already selected, the...
Read more >
methods and apparatuses for providing a reference array ...
The reference array input device can include a plurality of indicator detectors adapted to facilitate selection of a corresponding instruction associated ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found