admin icon indicating copy to clipboard operation
admin copied to clipboard

props become undefined after calling another URI

Open modiodio opened this issue 7 years ago • 0 comments

Hi there , I have a weird bug with react admin, the bug occurs in the screen. The code is below

<Show {...props}>
    <SimpleShowLayout>
            <TextField source="givenName"/>
            <TextField source="familyName"/>
            <DateField source="email"/>
            <ReferenceManyField label="" reference="user-projects" target="user" >
            	<Datagrid {...props}>
	                <ReferenceField label="Invitation receiver" source="user" reference="users" allowEmpty sortBy="user.givenName">
	                    <TextField source="givenName" />
	                </ReferenceField>
	                <TextField source="status"/>
	            </Datagrid>
            </ReferenceManyField>
    </SimpleShowLayout>
</Show>

CALL 1 : The action automatically fetch the user details below :

GET /api/users/1
{
	@context: "/api/contexts/User"
	@id: "/api/users/1"
	@type: "http://schema.org/Person"
	email: "[email protected]"
	givenName: "Martin"
	familyName: "Lelong"
}

CALL 2 : The call attached to the <ReferenceManyField> get the JSON below :

[
	{
		@id: "/api/user-projects/1"
		@type: "UserProject"
		id: "1"
		isAdmin: true
		isMember: true
		status: "ACCEPTED"
		user: {
			@id: "/api/users/1"
			@type: "http://schema.org/Person"
			givenName: "Martin"
			familyName: "Lelong"
		}
        }
]

I do not understand why the result of the "call 2" replace the result of the "call 1". I think there is a mechanism that detect the URL of the resource (@id: "/api/users/1") and replace it with the most recent result. The consequence of this is the "email" wich present in the "call 1" becomes undefined after the execution of the "call 2". Any idea ?

modiodio avatar Nov 09 '18 13:11 modiodio