Last active
February 9, 2019 11:16
-
-
Save jeswin/6f38ef1545ce994a63276dd43bc559f8 to your computer and use it in GitHub Desktop.
router-article-home-component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Home = ({ pathArr }) => { | |
const [pathInState, setPathFn] = useState(pathArr); | |
storePathInState = setPathFn; | |
return pathInState[0] === "todos" ? ( | |
// If the first part of the url is /todos, show the TodoList component | |
<TodoList todos={todos} pathArr={pathInState} /> | |
) : pathInState[0] === "about" ? ( | |
// If the first part of the url is /todos, show the TodoList component | |
<About /> | |
) : ( | |
// Otherwise show the home page. | |
<div> | |
There are two links: <br /> | |
1.{" "} | |
<a href="#" onClick={createClickHandler("/todos")}> | |
Todos page | |
</a> | |
<br /> | |
2.{" "} | |
<a href="#" onClick={createClickHandler("/about")}> | |
About page | |
</a> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment