React Router v5 code import * as React from " react" ![]() React Router v6 provides a useParams() hook (also in 5.1) that allows you to access the current URL params wherever you need them. To demonstrate how your code is improved with hooks in v6, let's start with something really simple like accessing the params from the current URL pathname. it's ours too! Our minified gzipped bundle size dropped by more than 50% in v6! React Router now adds less than 4kb to your total app bundle, and your actual results will be even smaller once you run it through your bundler with tree-shaking turned on. This means your v6 code will be much more compact and elegant than your v5 code.Īlso, it's not just your code that's getting smaller and more efficient. They are such an efficient low-level primitive that we were able to eliminate a lot of the boilerplate code by providing hooks that do the job instead. I'll wait.Īlthough we bolted a few hooks onto v5 in 5.1, React Router v6 was built from scratch using React hooks. If you don't remember that talk, you should probably just stop here and go watch it. You may remember Ryan's talk introducing hooks to the world at React Conf 2018 and how a lot of the code that we were all used to writing with React's "lifecycle methods" just sort of melts away as you refactor class-based React code to hooks. Why Another Major Version?Įasily the single biggest reason for a new router release is the advent of React hooks. But we are also going to talk about business and what you can expect from us (hint: it's very colorful). Today I want to focus on the future and how we are drawing on our experiences from the past to build the strongest possible future for the React Router project and the incredible React community. In fact, we completely changed our business model! Some of it has been rough, but hopefully you've experienced some new growth as well. We've all been through a lot over the last few years. But I don't want to bore you with the past. I could easily write at least a few pages about each of the bullet points above and its significance to both our business and the open source project we've been managing since 2014.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |