-
Notifications
You must be signed in to change notification settings - Fork 4
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
Upgrade to react-select v2 #58
Conversation
Codecov Report
@@ Coverage Diff @@
## master #58 +/- ##
==========================================
- Coverage 100% 99.13% -0.87%
==========================================
Files 59 60 +1
Lines 542 581 +39
Branches 118 128 +10
==========================================
+ Hits 542 576 +34
- Misses 0 5 +5
Continue to review full report at Codecov.
|
75f8b4d
to
35d3e11
Compare
value={44} | ||
valueKey="value" | ||
/> | ||
<div |
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.
Ideally we'd like to keep this mocked to <Select.Async>
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.
Yup. Can create a mock for the new Select.js
component as well to cover this case, similar to:
https://github.com/uptick/react-object-list/blob/master/__mocks__/react-select.js
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.
As recommended by @scaredcat I've updated the react-select
mock to provide a better name for Select.Async
.
} | ||
} | ||
|
||
return nextProps |
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.
if I try
const props = {
value: 101010
}
const transform = {
value: ['value', val => parseInt(val.toString(), '2')]
}
convertProps(props, transforms) // {val: 101010}
since KNOWN_PROPS
overwrites the transform of 'value' back to the original value.
this function would only work if a value transform does not save it back to the original prop key
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.
Yep, that's the intended behavior. Anything that needs a transform would be removed from KNOWN_PROPS
; it's just a way of avoiding errors being thrown out for props that don't need a transform.
value={44} | ||
valueKey="value" | ||
/> | ||
<div |
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.
Yup. Can create a mock for the new Select.js
component as well to cover this case, similar to:
https://github.com/uptick/react-object-list/blob/master/__mocks__/react-select.js
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.
react-select 2 has significant UI changes as well, impacting the APILists on workforce. Do we need get UX team approval?
@@ -1,6 +1,6 @@ | |||
import React from 'react' | |||
import PropTypes from 'prop-types' | |||
import Select from 'react-select' | |||
import Select from '../../utils/Select' |
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 is used below to determine propTypes. Happy to simply change the proptype check to a catch all propTypes.object
and removing this line.
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.
@scaredcat This should be working now; I've added react-select
prop types into the wrapper.
I was thinking I could at least change the background of the select input to white to make it look close to the previous version. I'll also run it past the product team. |
@scaredcat @tabby-or-not Okay, I've patched up a few of the issues raised, how do we feel about it now? |
Workforce is upgrading to
react-select
v2, and so we need to bumpreact-object-list
too. I've used the same approach as for Workforce; create a thin wrapper that manages converting the API from v1 to v2 for us, so we don't have to change each usage ofreact-select
.I've noticed that a couple of strange warnings appear in the console as a result of prop types:
It looks like we're passing undefined to a prop type definition somewhere, but that seems pretty strange to me. Probably need someone more familiar with how this package works to take a look.
There were a lot of snapshot tests that needed updating, I went through them and couldn't spot anything wrong.