My question is very trivial but I've got completely lost.
I'm using Reactjs. I've got an array of objects like this:
const modules = [
{
thematicArea: "Topic 1",
id: 1,
name: "Name 1",
details: [
"Lorem ipsum",
"Lorem ipsum 2"
]
},
{
thematicArea: "Topic 2",
id: 2,
name: "Name 2",
details: [
"Lorem ipsum",
"Lorem ipsum 2"
]
},
{
thematicArea: "Topic 3",
id: 3,
name: "Name 3",
details: [
"Lorem ipsum",
"Lorem ipsum 2"
]
},
{
thematicArea: "Topic 1",
id: 4,
name: "Name 4",
details: [
"Lorem ipsum",
"Lorem ipsum 2"
]
},
{
thematicArea: "Topic 3",
id: 5,
name: "Name 5",
details: [
"Lorem ipsum",
"Lorem ipsum 2"
]
}
]
I want to render it as:
Topic 1:
- Name 1
- Name 4
Topic 2:
- Name 2
Topic 3:
- Name 3
- Name 5
So far I've tried to use LoDash _.groupBy and juggled some mapKeys, mapValues but as I said at the beginning - I've completely lost. Please, help me to find the best solution...
https://codesandbox.io/s/8p21n6p09l -> here is a sandbox where I need to implement the solution. A source object is in App.js and I've tried to use LoDash in components -> thematicArea.jsx Hope it'll help in helping me ; )