reactjs - Update passing parameter to function in Javascript/React-Native -


trying in react-native.

my function :

myfunction(theid = 0) {   return object.keys(this.props.posts)     .filter(/* added filter */)     .map((key, idx) => {       const post = this.props.posts[key];       return (         <view key={idx}>            <text>             { post.theid } - { post.name }           </text>            {this.myfunction(post.theid)}  //this not getting executed          </view>       );     }); } 

i'm passing value 0 theid myfunction(theid = 0) when i'm calling again within function , want pass value of returned data, it's not working. need here pass value theid? tried {this.myfunction(theid=post.theid)} did not work.

please help.

you never reference argument variable in code provided.

{this.myfunction(post.theid)} 

that code looking property named theid on object post. not looking @ given argument.

i take want call this.myfunction(post.theid) and, if post.theid undefined, instead pass in 0? in case, write this;

{this.myfunction(post.theid || 0)} 

and remove argument top of function definition.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -