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

ReferenceInput Uncaught TypeError: Cannot read property 'data' of undefined #4614

Closed
bateview opened this issue Apr 1, 2020 · 4 comments
Closed

Comments

@bateview
Copy link

bateview commented Apr 1, 2020

Here is how I used:

<ReferenceInput source="category1" reference="category1">
    <SelectInput optionText="name" optionValue="id" />
</ReferenceInput>

What you were expecting:

I clearly have id and name for each object.
Here is my endpoint: locahost:8000/category1 return

[
    {
        "id": 1,
        "name": "unknown",
        "slug": "unknown"
    },
    {
        "id": 2,
        "name": "animals & pet supplies",
        "slug": "animals & pet supplies"
    }
]

What happened instead:

Here is the error I got:

possibleValues.js:43 Uncaught TypeError: Cannot read property 'data' of undefined
The error may be correlated with this previous error:
TypeError: Cannot read property 'data' of undefined
    at http://localhost:3000/static/js/1.chunk.js:285549:27
    at Array.map (<anonymous>)
    at getPossibleReferences (http://localhost:3000/static/js/1.chunk.js:285548:25)
    at Object.current (http://localhost:3000/static/js/1.chunk.js:275027:82)
    at Subscription.checkForUpdates [as onStateChange] (http://localhost:3000/static/js/1.chunk.js:349728:47)
    at Subscription.handleChangeWrapper (http://localhost:3000/static/js/1.chunk.js:350038:12)
    at http://localhost:3000/static/js/1.chunk.js:349966:20
    at batchedUpdates$1 (http://localhost:3000/static/js/1.chunk.js:340392:16)
    at Object.notify (http://localhost:3000/static/js/1.chunk.js:349962:7)
    at Subscription.notifyNestedSubs (http://localhost:3000/static/js/1.chunk.js:350033:20)
    at Subscription.checkForUpdates [as onStateChange] (http://localhost:3000/static/js/1.chunk.js:348818:9)
    at Subscription.handleChangeWrapper (http://localhost:3000/static/js/1.chunk.js:350038:12)
    at http://localhost:3000/static/js/1.chunk.js:349966:20
    at batchedUpdates$1 (http://localhost:3000/static/js/1.chunk.js:340392:16)
    at Object.notify (http://localhost:3000/static/js/1.chunk.js:349962:7)
    at Subscription.notifyNestedSubs (http://localhost:3000/static/js/1.chunk.js:350033:20)
    at Subscription.handleChangeWrapper (http://localhost:3000/static/js/1.chunk.js:350038:12)
    at dispatch (http://localhost:3000/static/js/1.chunk.js:357280:7)
    at http://localhost:3000/static/js/1.chunk.js:226584:18
    at http://localhost:3000/static/js/1.chunk.js:214950:22
    at dispatch (http://localhost:3000/static/js/1.chunk.js:357698:28)
    at http://localhost:3000/static/js/1.chunk.js:212919:12
    at http://localhost:3000/static/js/1.chunk.js:214011:54
    at exec (http://localhost:3000/static/js/1.chunk.js:213557:5)
    at flush (http://localhost:3000/static/js/1.chunk.js:213615:5)
    at asap (http://localhost:3000/static/js/1.chunk.js:213572:5)
    at runPutEffect (http://localhost:3000/static/js/1.chunk.js:214007:3)
    at runEffect (http://localhost:3000/static/js/1.chunk.js:214743:7)
    at digestEffect (http://localhost:3000/static/js/1.chunk.js:214810:5)
    at next (http://localhost:3000/static/js/1.chunk.js:214700:9)
    at currCb (http://localhost:3000/static/js/1.chunk.js:214790:7)


    at http://localhost:3000/static/js/1.chunk.js:285549:27
    at Array.map (<anonymous>)
    at getPossibleReferences (http://localhost:3000/static/js/1.chunk.js:285548:25)
    at http://localhost:3000/static/js/1.chunk.js:275027:82
    at useSelectorWithStoreAndSubscription (http://localhost:3000/static/js/1.chunk.js:349708:23)
    at useSelector (http://localhost:3000/static/js/1.chunk.js:349784:12)
    at useGetMatchingReferenceSelector (http://localhost:3000/static/js/1.chunk.js:275029:73)
    at http://localhost:3000/static/js/1.chunk.js:274981:28
    at useReferenceInputController (http://localhost:3000/static/js/1.chunk.js:275370:101)
    at ReferenceInput (http://localhost:3000/static/js/1.chunk.js:305758:196)
    at renderWithHooks (http://localhost:3000/static/js/1.chunk.js:333472:22)
    at updateFunctionComponent (http://localhost:3000/static/js/1.chunk.js:335653:24)
    at beginWork (http://localhost:3000/static/js/1.chunk.js:337184:20)
    at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/1.chunk.js:318848:18)
    at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/1.chunk.js:318897:20)
    at invokeGuardedCallback (http://localhost:3000/static/js/1.chunk.js:318950:35)
    at beginWork$1 (http://localhost:3000/static/js/1.chunk.js:341734:11)
    at performUnitOfWork (http://localhost:3000/static/js/1.chunk.js:340698:16)
    at workLoopSync (http://localhost:3000/static/js/1.chunk.js:340674:26)
    at performSyncWorkOnRoot (http://localhost:3000/static/js/1.chunk.js:340292:13)
    at http://localhost:3000/static/js/1.chunk.js:329806:28
    at unstable_runWithPriority (http://localhost:3000/static/js/1.chunk.js:359678:16)
    at runWithPriority$1 (http://localhost:3000/static/js/1.chunk.js:329752:14)
    at flushSyncCallbackQueueImpl (http://localhost:3000/static/js/1.chunk.js:329801:11)
    at flushSyncCallbackQueue (http://localhost:3000/static/js/1.chunk.js:329789:7)
    at batchedUpdates$1 (http://localhost:3000/static/js/1.chunk.js:340398:11)
    at Object.notify (http://localhost:3000/static/js/1.chunk.js:349962:7)
    at Subscription.notifyNestedSubs (http://localhost:3000/static/js/1.chunk.js:350033:20)
    at Subscription.handleChangeWrapper (http://localhost:3000/static/js/1.chunk.js:350038:12)
    at dispatch (http://localhost:3000/static/js/1.chunk.js:357280:7)
    at http://localhost:3000/static/js/1.chunk.js:226584:18
    at http://localhost:3000/static/js/1.chunk.js:214950:22
    at dispatch (http://localhost:3000/static/js/1.chunk.js:357698:28)
    at http://localhost:3000/static/js/1.chunk.js:212919:12
    at http://localhost:3000/static/js/1.chunk.js:214011:54
    at exec (http://localhost:3000/static/js/1.chunk.js:213557:5)
    at flush (http://localhost:3000/static/js/1.chunk.js:213615:5)
    at asap (http://localhost:3000/static/js/1.chunk.js:213572:5)
    at runPutEffect (http://localhost:3000/static/js/1.chunk.js:214007:3)
    at runEffect (http://localhost:3000/static/js/1.chunk.js:214743:7)
    at digestEffect (http://localhost:3000/static/js/1.chunk.js:214810:5)
    at next (http://localhost:3000/static/js/1.chunk.js:214700:9)
    at currCb (http://localhost:3000/static/js/1.chunk.js:214790:7)

Steps to reproduce:

Related code:

insert short code snippets here

Other information:

Environment

  • React-admin version: 3.3.3
  • Last version that did not exhibit the issue (if applicable):
  • React version:
  • Browser:Chrome
  • Stack trace (in case of a JS error):
@bateview
Copy link
Author

bateview commented Apr 1, 2020

Found issue, you have to have the reference Resource in
For example:

        <Admin>
            <Resource name="products" list={ProductList} create={ProductsCreate} edit={ProductsEdit} />
            <Resource name="category1"/>
        </Admin>

@Kmaschta
Copy link
Contributor

Kmaschta commented Apr 7, 2020

Thanks for having answered your own issue!
I'm closing this one, but I opened another issue in order to improve the developer experience for that issue. (#4656)

@Kmaschta Kmaschta closed this as completed Apr 7, 2020
@jeremyrajan
Copy link

Thank you :). I spent time hours to figure out why haha. Maybe this can be part of the documentation somewhere @Kmaschta? :)

@fzaninotto
Copy link
Member

#4744 addresses this bug.

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

No branches or pull requests

3 participants