Skip to content

Commit a04562d

Browse files
committed
renamed hook
1 parent 89a4892 commit a04562d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/js/App.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React from "react";
22
import TODO from './TODO';
33

4-
import { useFetch } from './jexia/useFetch';
4+
import { useList } from './jexia/useList';
55

66
const App = () => {
7-
const [ data, loading ] = useFetch("todos");
7+
const [ data, loading ] = useList("todos");
88

99
return (
1010
<React.Fragment>
1111
{
1212
loading ?
13-
(<h1>loading from Jexia...</h1>)
13+
(<h1>Loading Todos from Jexia...</h1>)
1414
: (<TODO todos={ data }/>)
1515
}
1616
</React.Fragment>

src/js/jexia/useFetch.js renamed to src/js/jexia/useList.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import React, { useState, useEffect } from 'react';
22

33
import { list } from './index';
44

5-
const useFetch = (dataSet) => {
5+
const useList = (dataSet) => {
66
const [data, setData] = useState([]);
77
const [loading, setLoading] = useState(true);
88

9-
async function fetchData() {
10-
console.log('fetchData');
9+
async function listData() {
10+
console.log('useList');
1111
let records = await list(dataSet);
1212
setData(records);
1313
setLoading(false);
1414
}
1515

1616
useEffect(() => {
17-
fetchData();
17+
listData();
1818
}, [dataSet]);
1919

2020
return [ data, loading ];
2121
};
2222

23-
export { useFetch };
23+
export { useList };

0 commit comments

Comments
 (0)