Creating a container component by connect() function with defined mapStateToProps gives access to state (store.getState()) of entire tree state.
For example, I have combined state tree:
{
loaded: true,
threads: [
{
id: 1,
title: "Thread 1",
messages: [
{
id: 1,
text: "Message 1"
}
]
},
{
id: 1,
title: "Thread 2",
messages: [
{
id: 2,
text: "Message 2"
},
{
id: 3,
text: "Message 3"
}
]
}
]
}
How should I access particulary messages of given thread?
const mapStateToProps = (state) => {
return {
messages: getMessagesByThread(state.threads, <threadId>)
}
}
In this case lets assume that I don't want to have 'activeThreadId' param in store state tree (store.getState().activeThreadId).
What is the best other possibility to provide threadId?