-2

I am looking to reference the total-fees property of an object:

The object

In react, the '-' causes problems in referencing this property. I have tried using camelCase, and quotations marks, but no luck.

The code attempt

Kevin B
  • 94,570
  • 16
  • 163
  • 180
DaveZ
  • 11
  • 2
  • replace .total-fees with ['total-fees'], what you write is property 'total' from original minus fees variable – elirand5 Sep 29 '21 at 20:29

2 Answers2

0

Got it :D

data.row.original['total-fees']

DaveZ
  • 11
  • 2
-1

You are using negate symbol(!) with the key, data.row.original.total-fees. What this means is that your return statement will run only when data.row.original.total-fees is false or 0, but it is actually null.

So, what you can try is:

1). console.log(data.row.original.total-fees); //output: null

2). if(data.row.original.total-fees===null) return "Response";

metodribic
  • 1,561
  • 17
  • 27