react web game : switch, exact
This commit is contained in:
@@ -19,7 +19,11 @@ class GameMatcher extends Component {
|
|||||||
} else if (this.props.match.params.name === "lotto-generator") {
|
} else if (this.props.match.params.name === "lotto-generator") {
|
||||||
return <Lotto />;
|
return <Lotto />;
|
||||||
}
|
}
|
||||||
return <>게임이 없습니다.</>;
|
return (
|
||||||
|
<>
|
||||||
|
<div>게임이 없습니다.</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { BrowserRouter, HashRouter, Link, Route } from "react-router-dom";
|
import { BrowserRouter, Link, Route, Switch } from "react-router-dom";
|
||||||
import NumberBaseBall from "./games/NumberBaseball";
|
|
||||||
import RSP from "./games/RSP";
|
|
||||||
import Lotto from "./games/Lotto";
|
|
||||||
import GameMatcher from "./GameMatcher";
|
import GameMatcher from "./GameMatcher";
|
||||||
|
|
||||||
const Games = () => {
|
const Games = () => {
|
||||||
return (
|
return (
|
||||||
<HashRouter>
|
<BrowserRouter>
|
||||||
<div>
|
<div>
|
||||||
<Link to="/game/number-baseball?hello=world&query=10">숫자야구</Link>
|
<Link to="/game/number-baseball?hello=world&query=10">숫자야구</Link>
|
||||||
|
|
||||||
@@ -16,9 +13,12 @@ const Games = () => {
|
|||||||
<Link to="/game/index">GameMatcher</Link>
|
<Link to="/game/index">GameMatcher</Link>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Route path="/game/:name" component={GameMatcher} />
|
<Switch>
|
||||||
|
<Route exact path="/game" component={GameMatcher} />
|
||||||
|
<Route path="/game/:name" component={GameMatcher} />
|
||||||
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
</HashRouter>
|
</BrowserRouter>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user