Skip to content
Advertisement

How to solve Text strings must be rendered within a in nested map?

I’m not finding a way to solve this error in my nested map function , everything that I try ends up in a sintax error.

My code:

    {import codes....}
    const FormScreen = ({route}) => {
     const [FieldForm, setFieldForm] = useState([]);
     const [TypeForm, setTypeForm] = useState([]);
      useEffect(() => {
      if (FieldForm.length > 0) {   
        return;
      } else {
        setFieldForm(JSON.parse(route.params.paramKey).message);
        setTypeForm(JSON.parse(route.params.paramKey).tipo);
        console.log('SETINGGG',FieldForm,TypeForm);
      }
    },[FieldForm,TypeForm]);
return (<View>             
             {FieldForm.length > 0 ? (
                    FieldForm.map((item) => (
                      <>          
                        <Text>{`${JSON.stringify(item)}`}</Text>
                        <>
                        {TypeForm.map((type) => (  
                          <Text>{`${JSON.stringify(type)}`}</Text>
                        ))}
                        </>
                      </>
                    ))
                  ) : (
                    <Text key={uuid.v4()}> Loading ...</Text>
                  )}
            </View>

I tried to remove these components but it not worked, how can I make it work ?

Advertisement

Answer

 {TypeForm.map((type) => (  
    <Text>{`${JSON.stringify(type)}`}</Text>
 ))}; // remove this ; (dot and comma)
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement