I am assigning as default checked false
in this return Object, see the code
JavaScript
x
5
1
return Object.assign(file, {
2
temp_id: _.uniqueId(),
3
checked: false,
4
})
5
I have an exception, in case it is my first file dropped i want checked: true
,
I know that my first file dropped is when
const filePosition = files.length
returns 0
,
how can i apply this condition in my checked
?
Advertisement
Answer
If I understand correctly, you want to updated checked
to true
if file.length === 0
and false
and file.length !== 0
If that is correct, you can just do:
JavaScript
1
5
1
return Object.assign(file, {
2
temp_id: _.uniqueId(),
3
checked: files.length === 0,
4
})
5