I have next object:
Book = {
id: 1,
titel: "Some Book",
sections: [
{id: 1,
titel: "Section Titel",
pages: [
{id: 1, content: "Some text"},
{id: 2, content: "Some text"},
{id: 3, content: "Some text"}
]
},
{id: 2,
titel: "Section Titel",
pages: [
{id: 1, content: "Some text"},
{id: 2, content: "Some text"}
]
}
]
}
Book object stored in Redux store (state.Book).
I have component which visualizes this Book object.
Component Book renders one or more Section components and each Section component renders Page component.
Book subscribed to Redux over connect function from react-redux and listens to store.Book, hole object.
It is clear that when titel of the Book will change then hole Book object will be re-rendered including all Sections and Pages.
There are two questions:
Will react engine really re-render
SectionsandPagesif onlyBook.titelchanged? Or it will identify that other parts of the component do not changed and will not re-render them.If it will re-render then what is the best way to avoid it? Should I subscribe
SectionandPagecomponent to theStorealso? But it will not solve the problem, becauseBooklistens to holestate.Bookobject. Or should I subscribeBookcomponent only tostate.Book.idandstate.Book.titel, then usethis.context.storeinside to path data to the inner components?
Thanks in advance.