我從代碼中收到上述錯誤:<EditableContainer handleFn={this.onSaveTitle} component={FieldStyle}>{props.child}</EditableContainer>class EditableContainer extends React.Component<any, any> { render () { const {children, ...rest} = this.props const {edit} = this.state if (edit) { return ( <Component autoFocus onBlur={this.handleBlur.bind(this)} value={this.state.children} onChange={this.handleOnChange} render={(props) => this.props.component.render(props)} /> ) } }class FieldStyle extends React.Component<any, any> { render () { const {autoFocus, ...rest} = this.props // auto focus const ref = autoFocus ? (ref) => { this.ref = ref } : null return ( <TextField ref={ref} type="text" {...rest} /> ) }}正如你所看到的,我試圖使用帶有propEditableContainer的 React 來指定應該從哪個組件加載到實際組件本身。但是,我收到錯誤。Componentcomponent我究竟做錯了什么?
React:在返回的組件實例上找不到“render”方法:您可能忘記定義“render”
互換的青春
2023-07-14 10:19:49