simplify item rendering

This commit is contained in:
Ammar Ahmed
2021-06-13 14:58:54 +05:00
parent a4afe2249b
commit 103f6693e2

View File

@@ -25,22 +25,19 @@ const heights = {
header: 35,
};
const TrashI = ({item, index}) => {
return item.itemType === 'note' ? (
<NoteWrapper item={item} index={index} />
) : (
<NoteWrapper item={item} index={index} />
);
let renderItems = {
note: NoteWrapper,
notebook: NotebookWrapper,
topic: NotebookWrapper,
tag: TagItem,
section: SectionHeader,
};
let renderItems = {
notes: NoteWrapper,
notebooks: NotebookWrapper,
topics: NotebookWrapper,
tags: TagItem,
section: SectionHeader,
trash: TrashI,
};
const RenderItem = ({item,index}) => {
const Item = renderItems[item.itemType || item.type]
return <Item item={item} index={index} />
}
const SimpleList = ({
listData,
@@ -63,7 +60,6 @@ const SimpleList = ({
const [dataProvider, setDataProvider] = useState([]);
const scrollRef = useRef();
const [_loading, _setLoading] = useState(true);
const RenderItem = renderItems[type];
const refreshing = false;
useEffect(() => {