I have a type that I have defined in its own .ts file
export class FakeType {
value:{
name: string,
id: number
},
x: number
}
and I have an instance of that object in a .tsx file
let myObj: FakeType;
myObj = {
value:{
name: "Foo",
id: 99
},
x: 5
}
How can I programmatically create html elements corresponding to each field?
I can manually create my desired output as follows, but this won't work if FakeType
has hundreds of fields
return (
<div>Value: {myObj.value}</div>
<div>x: {myObj.x}</div>);
Note that I need access to both the field name and its value when I display it on a webpage.