Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetching data with Redux

What are the advantages of fetching data with Redux as described here compared to just using the regular pattern with

class Posts extends Component {
  state = { posts: [] };

  componentDidMount() {
    fetch(url).then(res => this.setState({ posts: res.json().posts });
  }

  render() {
    return ... 
  }
}

Is it to make asynchronous fetching easier? Does it make it easier to persist the data in the store, so I can retrieve it when I reopen the app without having to fetch again?

like image 479
Jamgreen Avatar asked Jun 27 '26 20:06

Jamgreen


1 Answers

It is actually not a question about why to fetch data from async actions, it seems you need to understand what advantages Redux library as a whole brings.

Read the article from Redux library author, whether you actually need Redux or not, or what advantages it brings: https://medium.com/@dan_abramov/you-might-not-need-redux-be46360cf367

like image 182
Shota Avatar answered Jun 29 '26 15:06

Shota