Reputation: 35
I have firebase key that I would like to pass from 1 component to the other, although it seems to just show as blank. In my List.js
I can see I am able to get the key (through this.props.item.key
) and display the key. But when I want pass it to Editblog.js
it does not show anything.
List.js
const { blogDescription, key, ownerId } = this.props.item.values;
Actions.edit_blog({ values: this.props.item.values });
I want to pass key to Editblog.js
here I find this.state.blogDescription
gives me the correct result but when I use this.state.key
it shows up as blank.
Editblog.js
this.state = {
blogDescription: props.values.blogDescription,
key: props.values.key,
ownerId: props.values.ownerId
};
<Text>{this.state.key}</Text>
Upvotes: 0
Views: 65
Reputation: 692
Most props on a JSX element are passed on to the component, however, there are two special props (ref
and key
) which are used by React, and are thus not forwarded to the component.
In your case you can pass the key as a different prop
Actions.edit_blog({ values: this.props.item.values, id: this.props.item.values.key });
And access it like this
this.state = {
blogDescription: props.values.blogDescription,
key: props.id,
ownerId: props.values.ownerId
};
<Text>{this.state.key}</Text>
Upvotes: 1