import React , { useEffect } from "react" ; import "./App.css" ; import { Switch , Route } from "react-router-dom" ; import Home from "./components/routes/Home" ; import Thread from "./components/routes/thread/Thread" ; import UserProfile from "./components/routes/userProfile/UserProfile" ; import { useDispatch } from "react-redux" ; import { UserProfileSetType } from "./store/user/Reducer" ; function App ( ) { const dispatch = useDispatch ( ) ; useEffect ( ( ) => { dispatch ( { type : UserProfileSetType , payload : { id : 1 , userName : "testUser" , } , } ) ; } , [ dispatch ] ) ; const renderHome = ( props ) => < Home { ... props } / > ; const renderThread = ( props ) => < Thread { ... props } / > ; const renderUserProfile = ( props ) => < UserProfile { ... props } / > ; return ( < Switch > < Route exact = { true } path = "/" render = { renderHome } / > < Route path = "/categorythreads/:categoryId" render = { renderHome } / > < Route path = "/thread/:id" render = { renderThread } / > < Route path = "/userprofile/:id" render = { renderUserProfile } / > < /Switch>); } export default App ;