Skip to content

Commit 9834fc4

Browse files
committed
add latestversion react component
1 parent c8f5d7a commit 9834fc4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/components/LatestVersion

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React, { useEffect, useState } from 'react';
2+
3+
const LatestVersion = () => {
4+
const [version, setVersion] = useState('Loading...');
5+
6+
useEffect(() => {
7+
const url = 'https://api.github.com/repos/lavanet/lava/releases/latest';
8+
9+
fetch(url, {
10+
headers: {
11+
'Accept': 'application/vnd.github+json',
12+
'X-GitHub-Api-Version': '2022-11-28',
13+
},
14+
})
15+
.then(response => response.json())
16+
.then(data => {
17+
setVersion(data.tag_name);
18+
})
19+
.catch(error => {
20+
console.error('Error fetching version:', error);
21+
setVersion('Failed to load version');
22+
});
23+
}, []);
24+
25+
return (
26+
version
27+
);
28+
};
29+
30+
export default LatestVersion;

0 commit comments

Comments
 (0)