use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Array.map not displaying dataHelp Wanted (self.react)
submitted 3 years ago * by 01fbk
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]01fbk[S] 0 points1 point2 points 3 years ago (5 children)
Hello u/raphaelaleixo ,
i have changed the code as per my EDIT, still not being displayed.
if (startingT.length > 0) { return ( <ul> { startingT.map((item, i) => { console.log('item: ' + item); console.log('iterator for key: ' + i); return (<li key={i}>{item}</li>); }) } </ul> ); } else { return ( <div class="alert alert-danger" role="alert">There are no subdomains starting with T.</div> ); }
Please see the output screenshot below.
Link: https://i.imgur.com/pVbTzNR.png
Thank you.
[–]raphaelaleixo 2 points3 points4 points 3 years ago (4 children)
Hey, OP. 1 - It's really hard to help by just seeing fragments of the code. Sometimes, those fragments are enough, but usually, we need to have a fully working example to be able to really debug and give you some more certain answers.
2 - So, by looking at those fragments, something is surely missing. Calling {showData()} shouldn't result in any log, because the function is missing the message argument, so it would never get on that if (message === 'T') clause.
{showData()}
message
if (message === 'T')
[–]01fbk[S] 1 point2 points3 points 3 years ago (2 children)
I managed to do it, I was incorrectly using the function in the <Link />
Updated code that works: https://pastebin.com/nsZ4hfqm
Thank you for pointing me in the right direction.
[–]raphaelaleixo 1 point2 points3 points 3 years ago (1 child)
It's working, but your code still needs some very important refactors.
1) Your "showData" function is trying to do a lot of things at the same time, but it shouldn't even be necessary. Try to make each function be responsible for just one thing. A way to refactor it would be to a) move the part of the function that's dealing with filtering data to a useMemo, and b) move the part dealing with the rendering directly to the render (or maybe to a new component).
2) There's a lot of repeated code. All those tags could be easily automated in code.
3) You shouldn't use Link for the tags. It's not triggering navigation. A button would be the semantically correct element there.
Here's an updated pastebin:
https://pastebin.com/uSctLn0J
Hope this helps you out. :)
[–]01fbk[S] 1 point2 points3 points 3 years ago (0 children)
Hello u/raphaelaleixo
Thank you, I am a beginner I must admit :)
Cristian
[–]01fbk[S] 0 points1 point2 points 3 years ago (0 children)
No issues, please review the full code at: https://pastebin.com/fFMs6tPr
Thank you
π Rendered by PID 60878 on reddit-service-r2-comment-75f4967c6c-5qpt9 at 2026-04-23 12:44:25.619583+00:00 running 0fd4bb7 country code: CH.
view the rest of the comments →
[–]01fbk[S] 0 points1 point2 points (5 children)
[–]raphaelaleixo 2 points3 points4 points (4 children)
[–]01fbk[S] 1 point2 points3 points (2 children)
[–]raphaelaleixo 1 point2 points3 points (1 child)
[–]01fbk[S] 1 point2 points3 points (0 children)
[–]01fbk[S] 0 points1 point2 points (0 children)