Skip to content

Commit

Permalink
Use more contextual variable names, and add inline logical && operator
Browse files Browse the repository at this point in the history
  • Loading branch information
zahrafalak committed Aug 18, 2024
1 parent 26023d4 commit 136cf25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
21 changes: 10 additions & 11 deletions src/views/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ import './Home.css';
import { SingleList } from '../components';

export function Home({ data, setListPath }) {
const dataPresent = data.length !== 0;
const hasList = data.length !== 0;
return (
<div className="Home">
<p>
Hello from the home (<code>/</code>) page!
</p>
<ul>
{dataPresent
? data.map((list, index) => (
<SingleList
key={index}
name={list.name}
path={list.path}
setListPath={setListPath}
/>
))
: null}
{hasList &&
data.map((list, index) => (
<SingleList
key={index}
name={list.name}
path={list.path}
setListPath={setListPath}
/>
))}
</ul>
</div>
);
Expand Down
7 changes: 3 additions & 4 deletions src/views/List.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { ListItem } from '../components';

export function List({ data }) {
const dataPresent = data.length !== 0;
const hasItem = data.length !== 0;
return (
<>
<p>
Hello from the <code>/list</code> page!
</p>
<ul>
{dataPresent
? data.map((item) => <ListItem key={item.id} name={item.name} />)
: null}
{hasItem &&
data.map((item) => <ListItem key={item.id} name={item.name} />)}
</ul>
</>
);
Expand Down

0 comments on commit 136cf25

Please sign in to comment.