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.

Used AutocompleteInput components give an error if the same name in "choice" object

See original GitHub issue

Playback steps:

 {/* ... */}
<AutocompleteInput
      label="Business"
      source="businessId"
      choices={[
        {
          id: "0",
          name: "sameName",
        },
        {
          id: "1",
          name: "sameName",
        },
        {
          id: "2",
          name: "otherName",
        },
      ]}
 {/* ... */}

Expected result: The key of the component is the identifier or any specified field in “choice” object.

The actual result: In console give ad error:

Warning: Encountered two children with the same key, `sameName`. 
Keys should be unique so that components maintain their identity across updates. 
Non-unique keys may cause children to be duplicated and/or omitted — 
the behavior is unsupported and could change in a future version.
    at ul
    at div
    at Paper 
    at div
    at PopperTooltip 
    at Portal 
    at PopperUnstyled 
    at Popper 
    at Autocomplete 
    at AutocompleteInput 
    at DropdownCt 
    at div
    at Box 
    at div
    at Stack 
    at div
    at CardContent 
    at DefaultComponent 
    at form
    at FormGroupsProvider 
    at FormProvider 
    at LabelPrefixContextProvider 
    at OptionalRecordContextProvider 
    at Form 
    at SimpleForm 
    at div
    at Box 
    at div
    at Paper 
    at Card 
    at div
    at div
    at CreateView 
    at RecordContextProvider 
    at SaveContextProvider 
    at CreateContextProvider 
    at CreateBase 
    at Create 
    at RatesCreateCt 
    at Routes 
    at ResourceContextProvider 
    at Resource 
    at Routes 
    at ErrorBoundary 
    at div
    at main
    at div
    at div
    at Layout 
    at Layout
    at div
    at Routes 
    at CoreAdminRoutes 
    at Routes 
    at CoreAdminUI 
    at AdminUI 
    at InnerThemeProvider 
    at ThemeProvider 
    at ThemeProvider 
    at ThemeProvider 
    at ResourceDefinitionContextProvider
    at NotificationContextProvider 
    at I18nContextProvider 
    at Router 
    at HistoryRouter 
    at InternalRouter 
    at BasenameContextProvider 
    at AdminRouter 
    at QueryClientProvider 
    at StoreContextProvider 
    at CoreAdminContext 
    at AdminContext 
    at Admin 
    at App`

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
BaurinVladislavcommented, Jul 21, 2022

What you were expecting: The key of the component is the id or any specified field in “choice” object.

What happened instead: In console give ad error:

Warning: Encountered two children with the same key, `Recurring title`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
    at ul
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at div
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at Paper (https://dl0vy9.sse.codesandbox.io/index.bundle.js:26629:83)
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at div
    at PopperTooltip (https://dl0vy9.sse.codesandbox.io/index.bundle.js:4173:5)
    at Portal (https://dl0vy9.sse.codesandbox.io/index.bundle.js:4521:5)
    at PopperUnstyled (https://dl0vy9.sse.codesandbox.io/index.bundle.js:4291:5)
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at Popper (https://dl0vy9.sse.codesandbox.io/index.bundle.js:27370:72)
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at Autocomplete (https://dl0vy9.sse.codesandbox.io/index.bundle.js:8475:83)

Steps to reproduce:

  1. open url - https://d7hlei.sse.codesandbox.io/#/comments
  2. Enter “Recurring title” in “Post” search input.
  3. Open console log in browser

Related code:

 {/* https://codesandbox.io/s/competent-moon-d7hlei?file=/src/comments/CommentList.tsx */}
 {/* ... */}
<ReferenceInput
    source="post_id"
    reference="posts"
    label="Post title serch"
    alwaysOn
  >
    {/* <SelectInput optionText="title" /> */}
    <AutocompleteInput optionText="title" />
  </ReferenceInput>
 {/* ... */}
 {/*https://codesandbox.io/s/competent-moon-d7hlei?file=/src/data.tsxx */}
export default {
  posts: [
    {
      id: 1,
      title: "Recurring title",
       {/* ... */}
    },
    {
      id: 2,
      title: "Recurring title",
       {/* ... */}
    },
    {
      id: 3,
      title: "Recurring title",
       {/* ... */}
    },
 {/* ... */}

Example CodeSandbox link
https://codesandbox.io/s/competent-moon-d7hlei

Environment

  • React-admin version: ^4.0.3
  • Last version that did not exhibit the issue (if applicable): probably in version 4.0, but maybe not true
  • React version: 18.2.0
  • Browser: 103.0.5060.114
  • Stack trace (in case of a JS error):
Warning: Encountered two children with the same key, `Recurring title`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
    at ul
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at div
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at Paper (https://dl0vy9.sse.codesandbox.io/index.bundle.js:26629:83)
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at div
    at PopperTooltip (https://dl0vy9.sse.codesandbox.io/index.bundle.js:4173:5)
    at Portal (https://dl0vy9.sse.codesandbox.io/index.bundle.js:4521:5)
    at PopperUnstyled (https://dl0vy9.sse.codesandbox.io/index.bundle.js:4291:5)
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at Popper (https://dl0vy9.sse.codesandbox.io/index.bundle.js:27370:72)
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at Autocomplete (https://dl0vy9.sse.codesandbox.io/index.bundle.js:8475:83)
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at AutocompleteInput (https://dl0vy9.sse.codesandbox.io/index.bundle.js:112411:29)
    at ChoicesContextProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:98770:23)
    at ResourceContextProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:94824:23)
    at ReferenceInput (https://dl0vy9.sse.codesandbox.io/index.bundle.js:114046:26)
    at div
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at FilterFormInput (https://dl0vy9.sse.codesandbox.io/index.bundle.js:120759:31)
    at form
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at LabelPrefixContextProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:102220:21)
    at FilterFormBase (https://dl0vy9.sse.codesandbox.io/index.bundle.js:120620:27)
    at FormProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:173213:13)
    at FilterForm (https://dl0vy9.sse.codesandbox.io/index.bundle.js:120577:31)
    at div
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at Toolbar (https://dl0vy9.sse.codesandbox.io/index.bundle.js:35179:82)
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:118221:25
    at ListView (https://dl0vy9.sse.codesandbox.io/index.bundle.js:167180:79)
    at ListContextProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:91919:20)
    at ResourceContextProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:94824:23)
    at ListBase (https://dl0vy9.sse.codesandbox.io/index.bundle.js:91766:23)
    at CommentList
    at Routes (https://dl0vy9.sse.codesandbox.io/index.bundle.js:157619:5)
    at ResourceContextProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:94824:23)
    at Resource (https://dl0vy9.sse.codesandbox.io/index.bundle.js:94729:24)
    at Routes (https://dl0vy9.sse.codesandbox.io/index.bundle.js:157619:5)
    at ErrorBoundary (https://dl0vy9.sse.codesandbox.io/index.bundle.js:149924:37)
    at div
    at main
    at div
    at div
    at https://dl0vy9.sse.codesandbox.io/index.bundle.js:590:66
    at Layout (https://dl0vy9.sse.codesandbox.io/index.bundle.js:115845:20)
    at __WEBPACK_DEFAULT_EXPORT__
    at div
    at Routes (https://dl0vy9.sse.codesandbox.io/index.bundle.js:157619:5)
    at CoreAdminRoutes (https://dl0vy9.sse.codesandbox.io/index.bundle.js:94590:79)
    at Routes (https://dl0vy9.sse.codesandbox.io/index.bundle.js:157619:5)
    at CoreAdminUI (https://dl0vy9.sse.codesandbox.io/index.bundle.js:94660:20)
    at AdminUI (https://dl0vy9.sse.codesandbox.io/index.bundle.js:104622:27)
    at InnerThemeProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:39499:70)
    at ThemeProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:39210:5)
    at ThemeProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:39519:5)
    at ThemeProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:117131:23)
    at ResourceDefinitionContextProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:94897:17)
    at NotificationContextProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:101099:23)
    at I18nContextProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:100562:17)
    at Router (https://dl0vy9.sse.codesandbox.io/index.bundle.js:157553:15)
    at HistoryRouter (https://dl0vy9.sse.codesandbox.io/index.bundle.js:101320:23)
    at InternalRouter (https://dl0vy9.sse.codesandbox.io/index.bundle.js:101240:23)
    at BasenameContextProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:101292:23)
    at AdminRouter (https://dl0vy9.sse.codesandbox.io/index.bundle.js:101229:22)
    at QueryClientProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:155619:21)
    at StoreContextProvider (https://dl0vy9.sse.codesandbox.io/index.bundle.js:101637:20)
    at CoreAdminContext (https://dl0vy9.sse.codesandbox.io/index.bundle.js:94529:30)
    at AdminContext (https://dl0vy9.sse.codesandbox.io/index.bundle.js:104567:20)
    at Admin (https://dl0vy9.sse.codesandbox.io/index.bundle.js:121296:30)
overrideMethod @ react_devtools_backend.js:4026
printWarning @ react-dom.development.js:67
error @ react-dom.development.js:43
warnOnInvalidKey @ react-dom.development.js:13620
reconcileChildrenArray @ react-dom.development.js:13651
reconcileChildFibers @ react-dom.development.js:14125
reconcileChildren @ react-dom.development.js:16997
updateHostComponent @ react-dom.development.js:17632
beginWork @ react-dom.development.js:19080
beginWork$1 @ react-dom.development.js:23940
performUnitOfWork @ react-dom.development.js:22776
workLoopSync @ react-dom.development.js:22707
renderRootSync @ react-dom.development.js:22670
performSyncWorkOnRoot @ react-dom.development.js:22293
(анонимная) @ react-dom.development.js:11327
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
flushSyncCallbackQueueImpl @ react-dom.development.js:11322
flushSyncCallbackQueue @ react-dom.development.js:11309
scheduleUpdateOnFiber @ react-dom.development.js:21893
dispatchAction @ react-dom.development.js:16139
(анонимная) @ hooks.js:15
(анонимная) @ hooks.js:50
Объект setTimeout (асинхронный)
(анонимная) @ hooks.js:49
invokePassiveEffectCreate @ react-dom.development.js:23487
callCallback @ react-dom.development.js:3945
invokeGuardedCallbackDev @ react-dom.development.js:3994
invokeGuardedCallback @ react-dom.development.js:4056
flushPassiveEffectsImpl @ react-dom.development.js:23574
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
flushPassiveEffects @ react-dom.development.js:23447
performSyncWorkOnRoot @ react-dom.development.js:22269
(анонимная) @ react-dom.development.js:11327
unstable_runWithPriority @ scheduler.development.js:468
runWithPriority$1 @ react-dom.development.js:11276
flushSyncCallbackQueueImpl @ react-dom.development.js:11322
flushSyncCallbackQueue @ react-dom.development.js:11309
discreteUpdates$1 @ react-dom.development.js:22420
discreteUpdates @ react-dom.development.js:3756
dispatchDiscreteEvent @ react-dom.development.js:5889
0reactions
BaurinVladislavcommented, Jul 22, 2022

That’s an old MUI issue (see here and there, etc.) that can be easily solved in React-Admin. A PR is in the stack.

Please tell me how me can easily solve the problem in React-Admin. Where to look? In what PR?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Autocomplete] Not working properly with repeated options ...
Used AutocompleteInput components give an error if the same name in "choice" object marmelab/react-admin#7996.
Read more >
React admin `AutocompleteArrayInput` shows [object, Object]
But when I do console log the choice prop in option text, the data is existed. The code snippet is : return (...
Read more >
Input Components - React-admin - Marmelab
React-admin provides a set of Input components, each one designed for a specific data type. Here is a list of the most common...
Read more >
How to Use The Autocomplete Component in Material-UI
There are two versions of the autocomplete that can be used: Combo box — Where the value of the text input must be...
Read more >
HTML attribute: autocomplete - MDN Web Docs
It is available on <input> elements that take a text or numeric value ... values if you do need to break the name...
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