defaultValue callback is never called
See original GitHub issueWhat you were expecting: I’m trying to setting a default uuid on a TextInput field as suggested in the documentation.
<TextInput
disabled
source='id'
defaultValue={() => uuidv4()}
/>
but it seems that the callback is never called and the field is empty even on form submit. By doing the following:
<TextInput
disabled
source='id'
defaultValue={uuidv4()}
/>
The defaultValue appears in the TextInput but in an ArrayInput the value would be always the same for each Array element because uuid4() is called only once.
Environment
- React-admin version: ^3.5.0
- React version: ^16.13.1
- Browser: Chrome 81 - Mac
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to set a default value for callback function? - Stack Overflow
log(`The Answer is ${cb(num1,num2)}`) } cal(3,2,mul); Here the code I tried to set a default value to callback function. let sum = (num1,num2) ......
Read more >Default value callback not called when used in recursion ...
If I'm recursively prompting a set of questions, the default value of a question is the generated value from the first iteration.
Read more >ReturnType of optional callback parameter? : r/typescript
I suspect the issue is that you are trying to assign a default value for a type that is generic. The default value...
Read more >Array.prototype.reduce() - JavaScript - MDN Web Docs
The reduce() method executes a user-supplied "reducer" callback function on ... reduce() does not mutate the array on which it is called, ...
Read more >TypeError: callback is not a function in JavaScript | bobbyhadz
Alternatively, you can define a default value for the callback parameter. This way you won't get an error even if no parameter is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

No,
cloneElementclones an element with its props.I’m having trouble using react-admin locally with npm link so I’ll try here. Could it be the missing
while cloning element the origin of the problem?
https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/form/SimpleFormIterator.js#L153