Why is my tmp object getting undefined values?
The fetch is getting the object right, maybe <FormStructure {...this.state.system} />
is the wrong syntax to give the Element the object?
export default class System extends React.Component<any, State> { constructor(props: any) { super(props); this.state = { system: new SystemClass(), } this.GetData(); } public render() { return ( <div> <FormStructure {...this.state.system} /> </div> ); } private GetData = (): void => { fetch('api/Admin/Get', { headers: { 'Content-Type': 'application/json' }, method: 'GET' }) .then(response => response.json()) .then(data => this.setState({ system: Helper.ConvertData(data, SystemClass) as SystemClass })) .then(() => console.log(this.state.system)) }; } const FormStructure = (system: SystemClass) => { const onFill = () => { var tmp = { name: system.name, street: system.street }; console.log(tmp); console.log(system); } }
https://stackoverflow.com/questions/65745662/object-undefined-values January 16, 2021 at 09:32AM
没有评论:
发表评论