0

this is my problem i hope there is a solution

./src/LineGraph.js
Syntax error: D:/programming/corona-tracker-app/covid-19-tracker/src/LineGraph.js: Unexpected token (88:12)

  86 |   return (
  87 |     <div>
> 88 |       {data?.length > 0 && (
     |             ^
  89 |         <Line
  90 |         options={options}
  91 |           data={{

code 1 code 2

0xlukc
  • 13
  • 5

1 Answers1

0

Based on you images of code, you handle null-safety (or having values) with a Typescript operator : ?.

And when you define data object using useState in line 67, assigned an empty object.

The LineGraph component ran and it rendered with an empty object, If you want to check if data has values, this may helps you:

Object.keys(data).length

So:

return(
<div>
    {Object.keys(obj).length === 0 && (
        <Line 
        // options
        />
    )}
</div>
)
Danial
  • 1,603
  • 2
  • 15
  • 24