Skip to content

Commit

Permalink
fix(client-electron): resolve hook issue in history page
Browse files Browse the repository at this point in the history
  • Loading branch information
marcincichocki authored May 28, 2021
1 parent 500edee commit 9adec4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
34 changes: 14 additions & 20 deletions src/client-electron/renderer/components/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import styled from 'styled-components';
import { memo } from 'react';
import { NavLink as RouterNavLink } from 'react-router-dom';
import { useContext } from 'react';
import { StateContext } from '../state';
import styled from 'styled-components';

const Nav = styled.nav`
display: flex;
Expand Down Expand Up @@ -32,20 +31,15 @@ export const NavLink = styled(RouterNavLink)`
}
`;

export const Navigation = () => {
const state = useContext(StateContext);
const { uuid } = state.history[0];

return (
<Nav>
<List>
<ListItem>
<NavLink to="/history">History</NavLink>
</ListItem>
<ListItem>
<NavLink to="/settings">Settings</NavLink>
</ListItem>
</List>
</Nav>
);
};
export const Navigation = memo(() => (
<Nav>
<List>
<ListItem>
<NavLink to="/history">History</NavLink>
</ListItem>
<ListItem>
<NavLink to="/settings">Settings</NavLink>
</ListItem>
</List>
</Nav>
));
3 changes: 1 addition & 2 deletions src/client-electron/renderer/pages/History.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ const H2 = styled.h2`

export const History: FC = () => {
const { history } = useContext(StateContext);
const { path } = useRouteMatch();

if (!history.length) return <NoHistory />;

const { path } = useRouteMatch();

return (
<HistoryWrapper>
<HistoryList>
Expand Down

0 comments on commit 9adec4e

Please sign in to comment.