MCPcopy Create free account
hub / github.com/SuboptimalEng/coding-tutorials / App

Function App

react-leetcode-clone/client/src/App.jsx:8–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import CodeMirror from '@uiw/react-codemirror';
7
8function App() {
9 const [code, setCode] = useState('');
10 const [testCaseResults, setTestCaseResults] = useState([]);
11
12 const checkCode = () => {
13 axios
14 .post('http://localhost:80/python', { code })
15 .then(({ data }) => {
16 setTestCaseResults(data.testCaseResults);
17 })
18 .catch((err) => console.log(err));
19 };
20
21 return (
22 <div className="App">
23 <header className="App-header">
24 <div className="absolute top-20 bottom-40 left-20 right-20 text-left">
25 <div>Create a function to add two numbers.</div>
26 <div className="flex space-x-2">
27 {testCaseResults.map((res, i) => {
28 return (
29 <div key={i}>
30 <div>{res === 'True' ? '✅ passed' : '❌ failed'}</div>
31 </div>
32 );
33 })}
34 </div>
35 <CodeMirror
36 value={code}
37 options={{
38 theme: 'dracula',
39 keyMap: 'sublime',
40 mode: 'python',
41 }}
42 onChange={(editor, data, value) => {
43 setCode(editor.getValue());
44 }}
45 className="w-96 h-80"
46 />
47 <div
48 onClick={() => checkCode()}
49 className="border-2 p-2 bg-green-600"
50 >
51 Submit Code
52 </div>
53 </div>
54 </header>
55 </div>
56 );
57}
58
59export default App;

Callers

nothing calls this directly

Calls 1

checkCodeFunction · 0.85

Tested by

no test coverage detected