Skip to content

Instantly share code, notes, and snippets.

View wildfrontend's full-sized avatar
:shipit:
something need to do

louis.luo wildfrontend

:shipit:
something need to do
  • DG
  • Taichung
View GitHub Profile

remix-run/react-router#4685

  1. add in
  2. add Global 404
Hey guys, so today I've came across this exact same issue and I was able to get something working to render a "global not found" component, while keeping the benefits of sharing some UI within a "parent" route. I wanted to share this with you, in case you find this useful for your case :)

Consider the routes I need to support:

prepare

  • rewrite fetch to catch httpcode
const httpCodeFetch = async ({ url, config = initialConfig }) => {
    const res = await fetch(url, config)
    if (res.status === 204) return {}
    if (res.ok) {
 return res.json()
@wildfrontend
wildfrontend / why we dont need to use --save-dev.md
Last active September 11, 2020 15:21
why we dont need to use `npm install --save-dev`

As of NPM 5, saving is done by default

--save-dev is only needed if we’re building a node app;

since we output minified JS for production via npm run build, everything is a dev dependency,

so it doesn’t actually matter in practice whether modules are added to dependencies or devDependencies in package.json.

@wildfrontend
wildfrontend / bulma-react-router.md
Last active September 30, 2020 03:54
How to use bulma tabs active class name on the parent element with React router

jgthms/bulma#3129

answer:

  const setParentAsActive = (node: any) => {
    if (node) {
 node.parentNode.className = node.className