File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1
1
import React , { useState } from 'react' ;
2
- import { BrowserRouter as Router , useLocation } from "react-router-dom" ;
2
+ import { BrowserRouter as Router , useLocation , useHistory } from "react-router-dom" ;
3
3
4
4
import Header from './Header/Header' ;
5
5
import Home from './Home/Home' ;
@@ -13,10 +13,16 @@ import './App.scss';
13
13
14
14
function App ( ) {
15
15
const location = useLocation ( ) ;
16
+ const history = useHistory ( ) ;
16
17
17
18
const suggestedCountry = location . pathname . slice ( 1 ) . toUpperCase ( ) ;
18
19
const country = countries . map ( country => country . value ) . includes ( suggestedCountry ) ? suggestedCountry : 'CL' ;
19
- const [ pais , handleSetPais ] = useState ( country ) ;
20
+ const [ pais , setPais ] = useState ( country ) ;
21
+
22
+ const handleSetPais = ( country ) => {
23
+ setPais ( country ) ;
24
+ history . push ( `/${ country . toLowerCase ( ) } ` ) ;
25
+ } ;
20
26
21
27
return (
22
28
< AppContext . Provider value = { {
You can’t perform that action at this time.
0 commit comments