|
[index.tsx]
export const Default = () => {
const [test, setTest] = useState<object[] | undefined>(undefined);
const columns: Column[] = [
{
field: "OrderID",
headerText: "Order ID",
width: "20%"
},
{
field: "CustomerID",
headerText: "Customer ID",
width: "30%"
},
{
field: "ShipName",
headerText:"Name",
width: "50%"
}
];
useEffect(() => {
axios
.get(
)
.then(({ data }) => {
setTest(data); //if you comment this line, the code/demo works perfectly
});
})
return (
<GridComponent
dataSource={datasource}
columns={columns}
>
</GridComponent>
);
}
|
|
[index.tsx]
export const Default = () => {
const [test, setTest] = useState({}); //demo state variable, just to show the problem (no further usage)
const columns: Column[] = [
new Column({
field: "OrderID",
headerText: "Order ID",
width: "20%"
}),
new Column({
field: "CustomerID",
headerText: "Customer ID",
width: "30%"
}),
new Column({
field: "ShipName",
headerText:"Name",
width: "50%"
})
];
useEffect(() => {
let a;
.then(({ data }) => {
a= data;
},[null,a]);
})
return (
<GridComponent
dataSource={datasource}
columns={columns}
>
</GridComponent>
);
}
|