Programmatically navigate with React Router

Programmatically navigate with #ReactJS Router:  by @tylermcginnis #JavaScript

  • The goal of this post is to break down the correct approaches to programmatically navigating with React Router v4.
  • What I love about React Router is its dedication to declarative, “React like” code.
  • The whole goal of the redesign to React Router v4 was to align React Router’s vision with React’s.
  • The primary way you programmatically navigate using React Router v4 is by using a component 🤯🤯🤯.
  • Going back to our example earlier, assuming the component is being rendered by React Router, our code could look like this – – Now, what if the component wasn’t being rendered by React Router?

When building an app with React Router, eventually you’ll run into the question of navigating programmatically. Because of the churn that React Router has gone through in the last few years, there are a lot of outdated, and frankly incorrect tutorials out there. The goal of this post is to break down the correct approaches to programmatically navigating with React Router v4.
Continue reading “Programmatically navigate with React Router”

Advanced React Component Patterns – kentcdodds

Advanced #ReactJS Component Patterns:  by @kentcdodds #JavaScript

  • Two of my courses will be (have now been) released as part of Egghead’s annual Christmas course release celebration 🎉 One is The Beginner’s Guide to ReactJS and the other is Advanced React Component Patterns.
  • 👀The course starts with a single lesson where I implement a simple toggle component that manages its own state.
  • My hope is that by doing things this way you can quickly identify the trade-offs of the different patterns and know when each pattern would be most appropriate.The course wraps up by refactoring the toggle component to a redux component affectionately called “Rendux.” I think that you’ll be blown away…
  • This way we can easily create custom components which have access to the toggle component’s on state and the toggle helper function.There are actually six lessons dedicated to Higher Order Components in this course.
  • Hopefully with this refactor you’ll see both the power and the simplicity of the render prop pattern.The basic idea of the pattern is that rather than have the toggle component be responsible for doing anything special in the render method, we delegate that responsibility over to the user and we…

An overview of some of the patterns covered in my recently released course (free until Friday). NOTE: This is a cross-post from my newsletter. I publish each email two weeks after it’s…
Continue reading “Advanced React Component Patterns – kentcdodds”