Andy Wilson
Andy Wilson

Reputation: 131

Unable to access props.index even though props has index

I have a list i need to render with a button that will onPress save a value to the store then change to a different route but the problem is that when I console.log(props) i get {"index":1, "title":"hello world"} but if I do console.log(props.index) i get blank it doesn't give me a value why is this?

Upvotes: 0

Views: 28

Answers (2)

MaximumLasagna
MaximumLasagna

Reputation: 194

Try to use an other prop name like "myCustomIndex", i'm not sure but maybe this keyword is not allowed in props.

Upvotes: 0

Louis Lecocq
Louis Lecocq

Reputation: 1814

Your error must come from something else. There is no problem with what you are describing, such as :

var props = {
  "index": 1,
  "something": "else"
}

console.log(props);
console.log(props.index);

Upvotes: 2

Related Questions