Replies: 1 comment 1 reply
-
返信が遅くなり申し訳ありません。その場合、 ただ、stateが絡んだ場合に https://codesandbox.io/s/sleepy-liskov-hm7rqx?file=/src/App.tsx: const isBoolean = (value: unknown): value is boolean =>
typeof value === "boolean";
const topRoutes = Rocon.Path()
.exact({
action: () => <p>Top Route</p>
})
.route("users");
const userWithState = topRoutes._.users
.attach(Rocon.Path())
.any("user_id")
.anyRoute.attach(Rocon.State("sampleState", isBoolean, { optional: true }))
.action(({ sampleState }) => <p>SampleState is {String(sampleState)}</p>);
export default function App() {
const renderedRoute = useRoutes(topRoutes);
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<ul>
<li>
<Link route={topRoutes.exactRoute}>Top</Link>
</li>
<li>
{" "}
<Link
route={userWithState.route}
match={{ sampleState: false, user_id: "uhyo" }}
>
SampleState=false
</Link>
</li>
<li>
<Link
route={userWithState.route}
match={{ sampleState: true, user_id: "uhyo" }}
>
SampleState=true
</Link>
</li>
</ul>
<hr />
{renderedRoute}
</div>
);
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
「users/:user_id」(location.stateに真偽値sampleStateを持つ)ルートの定義の仕方と、そこへの
<Link>
コンポーネントを使った遷移の仕方がわからず6時間悩んでいます。もしよければ教えていただきたいですm(__)m
Beta Was this translation helpful? Give feedback.
All reactions