![]() ![]() In addition, it automatically uses the immer library to let you write simpler immutable updates with normal mutative code, like = true. createReducer(): that lets you supply a lookup table of action types to case reducer functions, rather than writing switch statements.It can automatically combine your slice reducers, adds whatever Redux middleware you supply, includes redux-thunk by default, and enables use of the Redux DevTools Extension. configureStore(): wraps createStore to provide simplified configuration options and good defaults.Overall, whether you're a brand new Redux user setting up your first project, or an experienced user who wants to simplify an existing application, using Redux Toolkit will make your code better and more maintainable. However, we strongly recommend using Redux Toolkit for all Redux apps. There are many existing applications that use other Redux wrapper libraries, or write all Redux logic "by hand", and if you still prefer to use a different approach, go ahead! Note that you are not required to use Redux Toolkit to use Redux. It can be added at the start of a new project, or used as part of an incremental migration in an existing project. Redux Toolkit is beneficial to all Redux users regardless of skill level or experience. Redux Toolkit makes it easier to write good Redux applications and speeds up development, by baking in our recommended best practices, providing good default behaviors, catching mistakes, and allowing you to write simpler code. We can't solve every use case, but in the spirit of create-react-app and apollo-boost, we can provide an official recommended set of tools that handle the most common use cases and reduce the need to make extra decisions. "Redux requires too much boilerplate code"."I have to add a lot of packages to get Redux to do anything useful"."Configuring a Redux store is too complicated".Redux Toolkit was originally created to help address three common concerns about Redux: Or, maybe you're writing a larger application and finding yourself writing some similar code, and you'd like to cut down on how much of that code you have to write by hand. Sometimes we just want the simplest possible way to get started, with some good default behavior out of the box. This is good in some cases, because it gives you flexibility, but that flexibility isn't always needed. It lets you decide how you want to handle everything, like store setup, what your state contains, and how you want to build your reducers. The Redux core library is deliberately unopinionated. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |