Skip to content

Commit

Permalink
Changing the behaviour of List
Browse files Browse the repository at this point in the history
  • Loading branch information
Eimi Okuno authored and Eimi Okuno committed Sep 28, 2019
1 parent 84c3ac4 commit cd24dc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions packages/components/List/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import SimpleCard from '../SimpleCard';
import TranscriptCard from '../TranscriptCard';
import cuid from 'cuid';

const List = (props) => {

const [ items, setItems ] = useState(props.items);
const [ items, setItems ] = useState([]);

useEffect(() => {
if (items.length === 0) {
Expand All @@ -18,11 +19,12 @@ const List = (props) => {
}, [ props.items ]);

const listItems = items.map((item) => {
const key = 'card-' + cuid();
if (item.display && item.status) {
return (
<TranscriptCard
{ ...item }
key={ item.key }
key={ key }
handleEditItem={ props.handleEditItem }
handleDeleteItem={ props.handleDeleteItem }
/>
Expand All @@ -32,7 +34,7 @@ const List = (props) => {
return (
<SimpleCard
{ ...item }
key={ item.key }
key={ key }
handleEditItem={ props.handleEditItem }
handleDeleteItem={ props.handleDeleteItem }
/>
Expand Down
4 changes: 2 additions & 2 deletions packages/components/SearchBar/stories/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import List from '../../List';
import SearchBar from '..';

const cardActions = actions({
handleEdit: 'Edit button clicked',
handleDelete: 'Delete button clicked'
handleEditItem: 'Edit button clicked',
handleDeleteItem: 'Delete button clicked'
});

const searchActions = actions({ handleSearch: 'Handle search' });
Expand Down

0 comments on commit cd24dc9

Please sign in to comment.