Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Commit

Permalink
Time with dayjs
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptronicek committed Oct 18, 2020
1 parent e6fbd17 commit e24a5ac
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -16,6 +16,7 @@
"@react-navigation/stack": "^5.9.2",
"@ui-kitten/components": "^5.0.0",
"@ui-kitten/eva-icons": "^5.0.0",
"dayjs": "^1.9.3",
"expo": "^39.0.3",
"expo-status-bar": "~1.0.2",
"node-fetch": "^2.6.1",
Expand Down
16 changes: 12 additions & 4 deletions screens/home.component.js
Expand Up @@ -6,6 +6,10 @@ import { SafeAreaView, View, StyleSheet } from "react-native";
import { signOut } from "../src/auth/signout";
import { requestData } from "../src/app/api-req";

const dayjs = require('dayjs');
const relativeTime = require('dayjs/plugin/relativeTime');
dayjs.extend(relativeTime);

const data = new Array(5).fill({
title: 'Item',
});
Expand All @@ -15,7 +19,7 @@ const ListCustomItemShowcase = ( props ) => {
const renderItemHeader = (headerProps, info) => (
<View {...headerProps}>
<Text category='h6'>
{info.item.node.id}
{info.item.node.task}
</Text>
</View>
);
Expand All @@ -26,17 +30,21 @@ const ListCustomItemShowcase = ( props ) => {
</Text>
);

const renderItem = (info) => (
const renderItem = (info) => {

//const date = new Date(info.item.node.created_at);
return (
<Card
style={styles.item}
status='basic'
header={headerProps => renderItemHeader(headerProps, info)}
footer={footerProps => renderItemFooter(footerProps, info)}>
<Text>
{info.item.node.task}
Created {dayjs(info.item.node.created_at).fromNow()}
</Text>
</Card>
);
);
};

return (
props.data ?
Expand Down
1 change: 1 addition & 0 deletions src/app/api-req.js
Expand Up @@ -36,6 +36,7 @@ export const requestData = async (params) => {
}
id
task
created_at
}
}
}
Expand Down

0 comments on commit e24a5ac

Please sign in to comment.