Remix treats nested routes files differently. Its not simply a flat list of routes. Take this example-
routes
team
index.js
$username.js
team.js
function getOs() { | |
const MOD = /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'mac' : 'win'; | |
} |
import convertToRoutes from 'your-awesome-oss-pkg'; | |
const modules = { | |
'index.js': IndexComp, | |
'about.js': AboutComp, | |
'team.js': TeamComp, | |
'team/index.js': TeamIndexComp, | |
'team/join.js': TeamJoinComp, | |
'team/$username.js': TeamMemberComp, | |
}; |
Remix treats nested routes files differently. Its not simply a flat list of routes. Take this example-
routes
team
index.js
$username.js
team.js
interface Props<TParams> { | |
params: TParams, | |
path: string, | |
children: React.ReactChild, | |
} | |
const CustomLink = <TParams extends any>(props: Props<TParams>) => { | |
const { | |
path, | |
params, |
const { useEffect } = require("react"); | |
// Suffers from Stale Closures | |
export function useUpdatedExit(props) { | |
// initial = 0, latest = 0 | |
// initial = 0, latest = 1 | |
// initial = 0, latest = 2 | |
const { initial, latest, cb } = props; | |
function handleExit() { |
function sleep(duration, shouldFail) { | |
return new Promise((resolve, reject) => { | |
const cb = shouldFail ? reject : resolve; | |
setTimeout(() => cb(), duration); | |
}); | |
} |
function Actor({ name }) { | |
function sayHello() { | |
console.log('hello', name); | |
} | |
return ( | |
<button onClick={sayHello}> | |
Say Hello | |
</button> | |
); |
.redact { | |
background-color: #000 !important; | |
border-radius: 6px !important; | |
color: transparent !important; | |
filter: brightness(0) !important; | |
} |
const toastProps = { | |
purpose: 'alert', | |
variant: 'success', | |
isClosable: false, | |
onClose: handleClose, | |
root: { | |
'data-testId': 'root-wrapper', | |
}, | |
content: { | |
id: 'main-toast', |