2017-08-31 85 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);