I am trying to access to my objects value Id
but I am having troubles doing it and I do not really understand why.
My object looks like this:
The Id
value should be easily accessible by this code:
console.log('My object', this.props.record.Id);
or perhaps by this:
console.log('My object', this.props.record["Id"]);
But neither of those works, the website displays this error:
TypeError: Cannot read property 'Id' of undefined.
I also checked if this.props.record
is really an object using typeof
and it is an object.
Any ideas why is this happening?
Thank you in advance
This is mostly the scenario.
Commonly, props have initialValues
which you might have missed out there.
to confirm that, try doing this:
console.log('My object', this.props.record && this.props.record.Id);
To make the app run, you need first to include this this.props.record &&
before any usage of this.props.record.Id
, if it worked, we will work on setting a better solution to that problem by initializing a default value for record
property.