reactjs - How to get on the key of the parent from his child in Javascript? -


i want take name of parent highlight yellow i want take name of parent highlight yellow

let postref = fire.database().ref('users/').orderbykey().limittolast(100);     postref.on('child_added', snapshot => {         snapshot.foreach(childsnapshot => {             let author = snapshot.key;             childsnapshot.foreach(result => {                 let finaly = {text: result.val(), key: result.key , author: tostring(author)}                 this.setstate({posts: [finaly].concat(this.state.posts)})             })         })     })      postref.on('child_changed', snapshot => {         snapshot.foreach(childsnapshot => {             let author = snapshot.key;             childsnapshot.foreach(result => {                 let finaly = {text: result.val(), key: result.key , author: tostring(author)  }                 this.setstate({posts: [finaly].concat(this.state.posts)})             })         })     }) 

this show item database , posts.author show object undefined

<item.group>     {         this.state.posts.map(posts =>             <item key={posts.key} author={posts.author}color="red">                 <item.image size='tiny'                             src='https://turnkeyit.co.uk/assets/img/prose-icon-(blog).png'/>                  <item.content>                     <item.header>titolo</item.header>                     <item.meta>pubblicato alle /gg/mm/yy</item.meta>                     <item.description>                         {posts.text} {posts.key}                     </item.description>                     <item.extra>                         <button color="blue" floated='right'                                onclick={this.getpost.bind(posts.key)}> rivelati <icon                             name='heart'/> </button>                     </item.extra>                 </item.content>             </item>         )     } </item.group> 

and funcition call show uid

getpost(data){     alert(data) } 

with code, take value of posts of users, want make button take id user makes post. how can parents key?


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

php - Cannot override Laravel Spark authentication with own implementation -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -