feat(nvim-editor): fetch and display opened file
This commit is contained in:
@@ -1,8 +1,18 @@
|
||||
import { useState } from "react";
|
||||
import axios from "axios";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export const NvimEditor = (props: { source: string | undefined }) => {
|
||||
const [data, setData] = useState<string>();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
return <div className="h-full">{props.source}</div>;
|
||||
useEffect(() => {
|
||||
if (!props.source) return;
|
||||
setLoading(true);
|
||||
axios.get<string>(props.source).then(({ data }) => {
|
||||
setData(data);
|
||||
setLoading(false);
|
||||
});
|
||||
}, [props.source]);
|
||||
|
||||
return <div className="h-full">{loading ? "Loading..." : data}</div>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user