react web game : queryString, URLSearchParams

This commit is contained in:
haerong22
2021-03-26 21:50:29 +09:00
parent c9729c8e69
commit dbe91e8839
2 changed files with 8 additions and 1 deletions

View File

@@ -6,6 +6,12 @@ import RSP from "./games/RSP";
class GameMatcher extends Component {
render() {
console.log(this.props);
const urlSearchParams = new URLSearchParams(
this.props.location.search.slice(1)
);
console.log(urlSearchParams);
console.log(urlSearchParams.get("hello"));
if (this.props.match.params.name === "number-baseball") {
return <NumberBaseball />;
} else if (this.props.match.params.name === "rock-scissors-paper") {

View File

@@ -9,7 +9,8 @@ const Games = () => {
return (
<HashRouter>
<div>
<Link to="/game/number-baseball">숫자야구</Link>&nbsp;
<Link to="/game/number-baseball?hello=world&query=10">숫자야구</Link>
&nbsp;
<Link to="/game/rock-scissors-paper">가위바위보</Link>&nbsp;
<Link to="/game/lotto-generator">로또추첨기</Link>&nbsp;
<Link to="/game/index">GameMatcher</Link>