2017-08-31 70 views
0

對於字段的Redux表單文檔(http://redux-form.com/6.5.0/docs/api/Field.md/),它表示應該有一個onChange屬性(props.input.onChange),但我的組件不提供任何此類財產。字段組件不提供'input.onChange'屬性

const customComponent = props => { 
    console.log(`input: ${JSON.stringify(props.input)}`); 
    return (
     <Jsx ... /> 
    ); 
}; 


//Using it: 
<Field name="link_id" component={customComponent} /> 

這將打印input: {"name":"link_id","value":""} 是有什麼我做錯了什麼?

回答

0

您的組件具有這些屬性,它們不會被打印,因爲JSON.stringify不能將字符串化並輸出任何功能(例如onChange)。 您看到的正在運行您的代碼的只是您的Fieldnamevalue)的屬性,它們是字符串,因此可以字符串化和打印。

如果你想探索你Field對象只是在你的組件或使用斷點使用debugger或者乾脆 console.log(props.input.onChange);