Skip to content

Instantly share code, notes, and snippets.

View sdmhsn's full-sized avatar
:octocat:
Hello World

Saddam Husein sdmhsn

:octocat:
Hello World
  • Kota Kupang, Indonesia
View GitHub Profile
@sdmhsn
sdmhsn / composing-route-in-react-router-v6.md
Created November 21, 2022 03:52 — forked from mjackson/composing-route-in-react-router-v6.md
Notes on route composition in React Router v6, along with a suggested improvement you can make today to start upgrading

Composing <Route> in React Router v6

Composition of <Route> elements in React Router is changing in v6 from how it worked in v4/5 and in Reach Router. React Router v6 is the successor of both React Router v5 and Reach Router.

This document explains our rationale for making the change as well as a pattern you will want to avoid in v6 and a note on how you can start preparing your v5 app for v6 today.

Background

In React Router v5, we had an example of how you could create a element](https://github.com/remix-run/react-router/blob/320be7afe44249d5c025659bc00c3276a19f0af9/packages/react-router-dom/examples/Auth.js#L50-L52) to restrict access to certain routes on the page. This element was a simple [wrapper around an actual element that made a simple decision: is the user authenticated or not? If so, ren

@sdmhsn
sdmhsn / gist:4c2e7533030b4e17c9260411d067eb58
Created June 18, 2022 08:15 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote