How to set the value? of custom components using rc-form, in antd-mobile

class MixedInput extends Component {
    value = () => {
        return "xxx"
    }
    onChange = () => {
        console.log("set value")
        this.setState({ value: "xxx" });
    }
    render() {
        let options = this.props.items.map(function (option, idx) {
            return { value: option.value, label: option.text }
        });
        return (
            <div>
                <Picker data={options} cols={1}  onChange={this.onChange}>
                    <List.Item>{this.props.label}</List.Item>
                </Picker>
                <TextareaItem rows={3} onChange={this.onChange} />
            </div>
        )
    }
}
export default MixedInput

this setting does not work. The attribute value obtained in submit is always undefined,. Which god would trouble me to tell me the use of the custom component rc-form? thank you very much.


who is kind enough to help me


class MixedInput extends Component {


constructor(props) {
    super(props);
    this.state = {
      value: 1,
    };
  }
onChange = () => {
    console.log("set value")
    this.setState({ value: 'xxx' },()=>{
            this.props.onChange(this.state.value)
    });
}
render() {
    let options = this.props.items.map(function (option, idx) {
        return { value: option.value, label: option.text }
    });
    return (
        <div>
            <Picker data={options} cols={1}  onChange={this.onChange}>
                <List.Item>{this.props.label}</List.Item>
            </Picker>
            <TextareaItem rows={3} onChange={this.onChange} />
        </div>
    )
}

}
export default MixedInput


never wrote that. You can try passing getFieldProps to the subcomponents


value and onChange do not have to write their own getFieldProps will pass you just need to call within the component
in the component to pass the value you need to onChange (newValue), while value is in the getFieldProps ('name', {initialValue:'}) then the initial value


is used in antd components can be directly into the sub-component getFieldProps, and then separately packaged.
it's hard to say if it's not antd.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31285-2b5c3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31285-2b5c3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?