5

Inside this map no rendering happens but console.log prints the array elements.

{(repos.length > 0) ? repos.flatMap((v, i) => {
                                
if (e1 === (v[2]) && v[1].length>0) {
  v[1].map((e)=>{
    console.log(e)
    <div></div>//no view rendering..

prints these on console

dashboard.tsx?91c8:646 (2) ["0x78Ba3149274C76921249200c090cCFCF3Cc86e85", "0"]
dashboard.tsx?91c8:646 (2) ["0x4DD660E14E9d90eE5180b49c5833D4d0f5295daa", "0"]

this is also not rendering

v[1].map((e)=>("assasasa"))

check this out

https://codesandbox.io/s/sweet-architecture-ljo89?file=/src/App.js

7
  • 1
    Include more details. I think you are not returning the result inside the map. Commented Nov 21, 2020 at 10:14
  • ([1,2,3]).map((e)=>{return ("assasasa")} this is also not rendering Commented Nov 21, 2020 at 10:18
  • v[1].length =2 but not rendering with map console.log prints data Commented Nov 21, 2020 at 10:19
  • Update these things in the question itself Commented Nov 21, 2020 at 10:20
  • Still not getting the issue. Can you add a codesandbox. Commented Nov 21, 2020 at 10:23

3 Answers 3

4

You are not returning the result inside the map

 return (
    <div className="App">
      {box.map((e) => {
        return box.map((e) => {
          return "aassssaa";
        });
        //return ("aaaa")
      })}
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
    </div>
  );

code - https://codesandbox.io/s/hopeful-frog-n664n?file=/src/App.js:143-415

Sign up to request clarification or add additional context in comments.

Comments

3

You need to return the item you want to render.

For example:


{array.map( (element) => {
    return <div>{element}</div>
})

}```

Comments

0

I guess the problem is you are using {} inside .map() method, instead you should use () to render JSX.

{(repos.length > 0) ? repos.flatMap((v, i) => {
                                
if (e1 === (v[2]) && v[1].length>0) {

  v[1].map((e)=>
(
    {console.log(e)}
    <div>
     e
    </div>

)
}})}

2 Comments

still not rendering
Can you share repos ? I guess e itself is an array or object and hence the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.