简体   繁体   English

数组 React Native 上的多个映射

[英]Multiple map on array React Native

Use multiple Map on array.在数组上使用多个 Map。 I get error: SyntaxError: C:\\Users\\Laptop15\\Desktop\\React Native\\src\\screens\\Question.js: Unexpected token, expected "," (59:7)我收到错误: SyntaxError: C:\\Users\\Laptop15\\Desktop\\React Native\\src\\screens\\Question.js: Unexpected token, expected "," (59:7)

I use function that: {PytaniePush(quizDane.quest1)}我使用的函数是:{PytaniePush(quizDane.quest1)}

   function PytaniePush(myID) {
            if(quizDane && quizDane.quest1 && myID){
                myID.map((item, key)=>(
                    myID[key].map((item2, key2)=>(
                        return ({RadioPush(myID[key].item2)});
                    ));
                )); 
            }
        }

I want to console log with all elements in array and object: quest1->array[Object(A,B), Object(A,B)] Data look: that I want to get: A in 0 is ... B in 0 is ... A in 1 is ... B in 1 is ...我想与在阵列和对象的所有元素到控制台日志:quest1->阵列[对象(A,B),对象(A,B)]的数据的样子:我想获得:一个在0 ...是在乙0 是... A 合 1 是... B 合 1 是...

You have an syntax error in your code.您的代码中有语法错误。 Here is right code.这是正确的代码。

function PytaniePush(myID) {
  if (quizDane && quizDane.quest1 && myID) {
    myID.map((item, key) =>
      myID[key].map((item2, key2) => {
        return RadioPush(myID[key].item2);
      })
    );
  }
}

Next time when you will have a syntax error try to use Prettier to find error and improve format of your code.下次遇到语法错误时,请尝试使用Prettier查找错误并改进代码格式。

There are some syntax errors in your code.您的代码中有一些语法错误。 Try this one.试试这个。

function PytaniePush(myID) {
  if(quizDane && quizDane.quest1 && myID){
    myID.map((item, key) => myID[key].map((item2, key2) => { 
      return RadioPush(myID[key].item2);
    } ));
  }
}

Try to use an ES6 aware IDE.尝试使用支持 ES6 的 IDE。 That way you will not stumble upon this kind of issues.这样你就不会偶然发现这类问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM