Home > Enterprise >  How do I reference a piece of data's name with a '-' in it, using react/JS? [duplicat
How do I reference a piece of data's name with a '-' in it, using react/JS? [duplicat

Time:09-30

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

CodePudding user response:

Got it :D

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

CodePudding user response:

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";

  • Related