Taley'a Mirza (Talia)
Web tech advocate!
Let's see Official Docs
Redux gives you following benefits
Story of Web Town Park and town residents
The way of communication
Result
Redux Manufacturing Store
Result
Single State tree or not?
One thing to note is that we don’t intend Redux to be used for all state.
Just whatever seems significant to the app. I would argue inputs and animation state should be handled by React (or another ephemeral state abstraction). Redux works better for things like fetched data and locally modified models.
⁃Dan Abramov
Recommended not to use nested objects in reducers
{
"id": "123",
"author": {
"id": "1",
"name": "Paul"
},
"title": "My awesome blog post",
"comments": [
{
"id": "324",
"commenter": {
"id": "2",
"name": "Nicole"
}
}
]
}
{
result: "123",
entities: {
"articles": {
"123": {
id: "123",
author: "1",
title: "My awesome blog post",
comments: [ "324" ]
}
},
"users": {
"1": { "id": "1", "name": "Paul" },
"2": { "id": "2", "name": "Nicole" }
},
"comments": {
"324": { id: "324", "commenter": "2" }
}
}
}
Fat actionCreators thin reducers
What's the issue here!
It was too common source of mistakes. People would forget a default case and would return undefined inadvertently, and then wonder why state is resetting once in a while.
Never use unstable versions on production
Bonus Tip:
Default State: https://github.com/reduxjs/redux/issues/514
Cartoon Story:
https://almerosteyn.com/2016/08/redux-explained-again
By Taley'a Mirza (Talia)
The purpose of this talk is to introduce main use cases of redux and how it can be organized with react applications, about the issues you faced without knowing where you went wrong using anti-patterns and how they can be avoided by following best practices