Skip to content

Instantly share code, notes, and snippets.

@jeswin
Last active February 9, 2019 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeswin/6f38ef1545ce994a63276dd43bc559f8 to your computer and use it in GitHub Desktop.
Save jeswin/6f38ef1545ce994a63276dd43bc559f8 to your computer and use it in GitHub Desktop.
router-article-home-component
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