SelectField don't support null type
I've a SelectField with a list of options in my schema. One item can be null and if it's null it's crashing.
It seams that the field don't support a null value. It's a bit painful because if a property is not required it's logical that this property is null.
I've create an example in CodeSandbox for you : https://codesandbox.io/s/pkq11l9zk7.
Do you have an idea how to manage this use case ?
Look on this example https://codesandbox.io/s/2wyj92lx5j I think this should resolve this use case.
I've looked your example. But it doesn't work as expected, because of the following reasons :
- Your example don't do really what i need.
- In the getDerivedStateFromProps method you don't take the correct next props correctly.
- I don't want to have a form on the HTML for every items (maybe 4000 items). Hidden or not, the code is present on the page. Not so good for performance...
I've create a new sandbox to demonstrate the bug correctly :
Sandbox link : https://codesandbox.io/s/xrjxk9oozz
That's what I need to do :
- I have an object "Activity" which contains an other object "Category"
- The category object can be null, or contains and id or a name.
- In the form I only want to display one field for the category, not all object fields.
- The form should present the category in a SelectField.
- The SelectField options definition : id as value, name as label
- When submit, the category id should be null (if nothing selected) or a number.
BUG : With the sandbox implementation I made, it's crashing when the category is null !!
JSON Activity Object
activity : {
...,
category : {
id: xxx,
name: "xxx"
}
}
Behavior needed :
| category value | Display | Value on submit |
|---|---|---|
{category:null} |
![]() |
{category: null} |
{category: id: 1, name: "Category 1"} |
![]() |
{category: id: 1} |
@mprzodala or @wysher Any news about this issue ?

