) every month and major updates with breaking changes (e.g.
) every 6 to 12 months.
There are many good reasons for keeping your application’s dependencies up to date:
As a rule of thumb, you should update your application’s dependencies at least once every quarter. Following is a recommended order for updating dependencies in web applications built using React.
React 16 was released recently, and if you’re still using React
(or lower), it would be good idea to switch to
as soon as possible, not just for the improvements, but also because it includes several breaking changes. If you’re already on the latest version, you can go through the release notes or the official blog to track changes and decide when it makes sense for you to upgrade.
If your application wasn’t created using
, you should consider migrating to it, since it’s a really powerful tool with amazing new features being added every month. It also conveniently bundles all
(like Webpack, Babel, Jest etc.) into a single package called
, so you just have to update one package instead of dozens, without worrying about compatibility issues.
has a somewhat poor reputation for revamping the API over and over again, but let’s face it: it’s an indispensable library with no reasonable alternative (except its offspring
). React Router v4 is a complete rewrite and several new features and bug fixes are still being added with every minor release, so it would be a good idea to stay up to date.
Redux is a tiny library with a small and fairly stable API, so it really doesn’t need to be updated frequently (or at all). That said, Redux 4.0 was released recently, and it includes many improvements, so you should consider upgrading. Also, while Redux is quite stable, you might want to update the middleware and helper libraries like
etc. more frequently.
Once you the core dependencies have been upgraded, you can go over other dependencies one by one and update each one to the latest version. If you’re using VS Code, you can simply hover over a dependency to find the latest version.
For dependencies with breaking changes, you can decide whether to update immediately or later (if at all), on a case-by-case basis.
Remove Unused/Rarely Used Dependencies
Developers often install several libraries that do similar things just to try them out, and forget to remove them from
. Redundant, duplicate and unused dependencies should be removed while updating. If you’re doing this for the first time, don’t be surprised to find that 30–50% of the dependencies in
are never used in the project.
You should also consider removing dependencies that are used very infrequently or can be replaced with small helper functions. Libraries like
can add over 100 KB to your production bundle. Use a tool like BundlePhobia to decide whether a dependency is worth keeping, especially if it’s only used in a handful of places.
Updating your project’s dependencies can seems like a boring task, but it’s actually quite the opposite: you get to learn about exciting new features and improvements that can help you be more productive, improve the quality of your codebase and improve your application’s performance. And it really doesn’t take that long, if you do it frequently enough!
Level up your reading game by joining Hacker Noon now!