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

Fix react default value #577

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix react default value #577

wants to merge 2 commits into from

Conversation

MaxCloutier
Copy link

Trying to use defaultValue prop gave me this error as the value had a default value in the react wrapper.

Screen Shot 2020-07-15 at 10 33 44 AM

@yairEO
Copy link
Owner

yairEO commented Jul 15, 2020

why are you using defaultValue and not value?

@MaxCloutier
Copy link
Author

@yairEO I had issues trying to update the state of my parent component in the onChange event. The parent dictates the value of the component passed down to the tagify wrapper and I would get this error whenever the onChange triggered

Screen Shot 2020-07-15 at 9 09 44 AM

I tried a few different ways to use a reference instead of the value so that I would pass down only the initial value to Tagify, but it created a weird issue where onBlur Tagify would send an empty value to onChange, after looking into it, using defaultValue did exactly what I needed

@yairEO
Copy link
Owner

yairEO commented Jul 16, 2020

In the Tagify React demo i've shown how to update the list of tags from the parent component

https://codesandbox.io/s/tagify-react-wrapper-oempc?file=/src/CrazyTags.js

There is no problem with using value

@MaxCloutier
Copy link
Author

@yairEO here is my use case:

Version without my fix using value:
https://codesandbox.io/s/tagify-react-wrapper-v9ej1?file=/src/tagify/react.tagify.js
If you add a tag it will give you this error TypeError Cannot read property 'insertBefore' of null

Version with my fix using defaultValue:
https://codesandbox.io/s/tagify-react-wrapper-0o6jd?file=/src/tagify/react.tagify.js

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.

2 participants