CopyPastor

Detecting plagiarism made easy.

Score: 0.81451416015625; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2018-08-23
by Ahmed Yaser

Original Post

Original - Posted on 2016-06-02
by abhirathore2006



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Im having similar problem. can't get it fixed. Variation is an array, inside there is another array called variation, with objects _getVariations = () => {
const { variations } = this.state;
if (variations.length > 0) {
variations.map((vari) => { vari.variation.map((ivari) => { Object.keys(ivari).map((key) => { return ( <View style={styles.variationRow}> <View> <Text>{ivari[key]}</Text> </View> <View> <Image style={{ width: 25, height: 25 }} source={{ uri: ivari[key] }} /> </View> </View> ) }) }); }); } }
This can be done in multple ways.
1. As suggested above, before `return` store all elements in the array 2. Loop inside `return`
Method 1

let container =[]; let arr = [1,2,3] //can be anything array, object arr.forEach((val,index)=>{ container.push(<div key={index}> val </div>) /** * 1. All loop generated elements require a key * 2. only one parent element can be placed in Array * e.g. container.push(<div key={index}> val </div> <div> this will throw error </div> ) **/ }); return ( <div> <div>any things goes here</div> <div>{container}</div> </div> ) Method 2 return( <div> <div>any things goes here</div> <div> {(()=>{ let container =[]; let arr = [1,2,3] //can be anything array, object arr.forEach((val,index)=>{ container.push(<div key={index}> val </div>) }); return container; })()} </div> </div> )

        
Present in both answers; Present only in the new answer; Present only in the old answer;