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

Error accessing 'place_id' property when rendering component dynamically #328

Open
Shaxadhere opened this issue Jun 23, 2023 · 1 comment

Comments

@Shaxadhere
Copy link

Shaxadhere commented Jun 23, 2023

When using the component normally or having multiple instances of it on the same form and page, it works fine. However, an issue arises when rendering the component dynamically, such as when mapping it with an array and adding one more item to the array. The following error occurs:

Cannot read properties of undefined (reading 'place_id')
TypeError: Cannot read properties of undefined (reading 'place_id')
    at Object.getOptionValue (http://localhost:3000/static/js/bundle.js:286026:24)
    at Cr (http://localhost:3000/static/js/bundle.js:284243:14)
    at http://localhost:3000/static/js/bundle.js:284253:12
    at Array.some (<anonymous>)
    at xr (http://localhost:3000/static/js/bundle.js:284252:12)
    at mr (http://localhost:3000/static/js/bundle.js:284194:17)
    at http://localhost:3000/static/js/bundle.js:284215:13
    at Array.map (<anonymous>)
    at Ir (http://localhost:3000/static/js/bundle.js:284201:20)
    at http://localhost:3000/static/js/bundle.js:285290:25

Annotation 2023-06-23 172142

<AsyncSelect
      {...args.selectProps ?? {}}
      loadOptions={fetchSuggestions}
      getOptionValue={({ value }) => value.place_id} // Here is the error while accessing 'place_id'
/>

It seems that when rendering the component dynamically, the 'place_id' property becomes inaccessible. This issue needs to be investigated and resolved to ensure the component functions correctly in all scenarios.

Steps to Reproduce:

Render the component dynamically, such as by mapping it with an array and adding an extra item to the array.
Check the browser console for the error message mentioned above.

@Tintef
Copy link
Owner

Tintef commented Aug 26, 2024

@Shaxadhere Can you please provide a repo/codesandbox and steps to reproduce? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants