I've been stuck on this for a while.
Here's a part of my redux-state
state: {
teachers: [
{ teacherId: 'ttt1', teacherName: 'Susan', isCool: true, teachesAt: 'sss1'},
{ teacherId: 'ttt2', teacherName: 'Karen', isCool: false, teachesAt: 'sss2'},
{ teacherId: 'ttt3', teacherName: 'Bob', isCool: true, teachesAt: 'sss3'},
{ teacherId: 'ttt4', teacherName: 'Mike', isCool: false, teachesAt: 'sss1'},
],
schools: [
{ schoolId: 'sss1', schoolName: 'Washington'},
{ schoolId: 'sss2', schoolName: 'Lincoln'},
{ schoolId: 'sss3', schoolName: 'Jefferson'},
],
students: [
{ schoolIdEnrolled: 'sss1', studentName: 'Billy'},
{ schoolIdEnrolled: 'sss1', studentName: 'Steven'},
{ schoolIdEnrolled: 'sss2', studentName: 'Bobby'},
{ schoolIdEnrolled: 'sss3', studentName: 'Mikey'},
{ schoolIdEnrolled: 'sss3', studentName: 'Sally'},
{ schoolIdEnrolled: 'sss3', studentName: 'Cindy'},
{ schoolIdEnrolled: 'sss3', studentName: 'Mandy'},
],
classes: [...],
}
Can anyone dream up a way so that in the render method of my
React Component I can loop through my schools and calculate the number
of 'coolTeachers'
and 'studentCount'
for each school? Is this the
use-case for reselect?
My table needs to be like this:
SCHOOL______# OF COOL TEACHERS_______STUDENTS
Washington__________1_______________________2
Lincoln______________0_______________________1
Jefferson____________1_______________________4