-
Notifications
You must be signed in to change notification settings - Fork 26
Add default name to form components #147
Add default name to form components #147
Conversation
OK, finally got the chance to go back to this one. Love it. Perfect approach. I will merge the "make everything uncontrolled" branch into this and put the higher-order component in all the relevant components, I think we’ll be good to go. |
Works now. @Nevon mind to review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird to be a reviewer of my own PR...
Other than the leftover files that shouldn't be needed, it looks good to me.
@@ -0,0 +1,13 @@ | |||
import seededRandom from 'seed-random' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be needed anymore, right, since you're using the higher-order-components package instead. Same for lib/uniqueComponentName
.
And now the build is failing because there's an imprecise dependency of react. react-maskedinput seems to be importing a private module from react, which either no longer exists or has been moved. insin/react-maskedinput#76 |
c2b5190
to
53493ae
Compare
Fixes #67
So this is a first attempt at generating stable, unique names for form controls where the name is not specified as a prop.
I've only added it to the uncontrolled field at the moment, so to try it out, remove the
name
from one of the examples where it is used. When the control re-renders, the name should stay the same, and the name should be unique.The general idea is that we concatenate the component name with a UUIDv4, which is seeded using a counter in the closure. This means that the uuid will very likely be re-used, but only with other components. There should never be a complete name collision due to the component name being different.