Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Introduce useGetMatching and useReferenceArrayInputController #3698

Merged
merged 2 commits into from
Sep 17, 2019

Conversation

djhi
Copy link
Contributor

@djhi djhi commented Sep 16, 2019

  • useGetMatching
  • useReferenceArrayInputController
  • Fix tests

@djhi djhi added this to the 3.0.0 milestone Sep 16, 2019
Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encouraging!

const useReferenceArrayInputController = ({
basePath,
filter: defaultFilter,
filterToQuery = searchText => ({ q: searchText }),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the default value to a constant to avoid having a new function at every render, defeating your useMemo line 93

options
);

const finalReferenceRecords = referenceRecords.filter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a comment here, like "filter out not found references - happens when the dataProvider doesn't guarantee referential integrity"


const dataStatus = getDataStatus({
input,
// We merge the currently selected records with the matching ones, otherwise
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should move this comment up to line 115

const referenceSource = (resource, source) => `${resource}@${source}`;

/**
* Call the dataProvider with a GET_LIST verb and return the result as well as the loading state.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is the same as useGetList... You should tweak it so that readers understand the difference

Copy link
Contributor Author

@djhi djhi Sep 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is tweaked in the example. GET_MATCHING is actually sent as GET_LIST

*
* import { useGetMatching } from 'react-admin';
*
* const LatestNews = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad example

@djhi djhi changed the title [WIP] Introduce useGetMatching and useReferenceArrayInputController [RFR] Introduce useGetMatching and useReferenceArrayInputController Sep 17, 2019
@fzaninotto fzaninotto merged commit a160ef1 into next Sep 17, 2019
@fzaninotto fzaninotto deleted the use-get-matching branch September 17, 2019 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants