[英]Redux-form: Prevent Input automatically fill prop.input.value with selected files
我有一個在Field component = {{}}中使用的組件
在其中,我輸入了type =“ file”,所以當我選擇文件時,它將自動用所選文件填充prop.input.value。
但是我想用修改后的文件對象手動填充prop.input.value onChange。
選擇文件時如何防止它自動填充props.input.value?
您無法致電onChange,因此您將擁有
<Field component={({input:{onChange}})=> {<input type="file" >} name={name} />
調用onChange
函數時,該值將保留在商店中,這意味着您可以在中間執行任何操作
<Field component={({input:{onChange}})=> {<input type="file" onChange={(theValueOrValueContainerEvent)=>
{....whateveryouwant; onChange(theValueOrValueContainerEvent) }}>} name={name} />
因此,在您執行完所需的任何操作之后,您就可以從redux-form調用onChange來保留更改。
希望能幫助到你
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.