Update app on hashchange
This commit is contained in:
parent
c000c17a3b
commit
0a8685360f
1 changed files with 8 additions and 4 deletions
12
src/App.tsx
12
src/App.tsx
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
|
|
||||||
import SingleColumn from './layouts/SingleColumn';
|
import SingleColumn from './layouts/SingleColumn';
|
||||||
import CreateLinkTile from './components/CreateLinkTile';
|
import CreateLinkTile from './components/CreateLinkTile';
|
||||||
|
@ -36,9 +36,13 @@ const App: React.FC = () => {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (location.hash) {
|
const [hash, setHash] = useState(location.hash);
|
||||||
if (location.hash.startsWith('#/')) {
|
|
||||||
page = <LinkRouter link={location.hash.slice(2)} />;
|
useEffect(() => (window.onhashchange = () => setHash(location.hash)), []);
|
||||||
|
|
||||||
|
if (hash) {
|
||||||
|
if (hash.startsWith('#/')) {
|
||||||
|
page = <LinkRouter link={hash.slice(2)} />;
|
||||||
} else {
|
} else {
|
||||||
page = (
|
page = (
|
||||||
<Tile>
|
<Tile>
|
||||||
|
|
Loading…
Reference in a new issue