-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(demo): better demo * feat(demo): better demo * feat(demo): better demo * feat(demo): better demo * feat(demo): better demo * feat(demo): better demo * feat(demo): better demo * feat(demo): better demo * feat(demo): better demo
- Loading branch information
1 parent
301acfe
commit 08a21f8
Showing
14 changed files
with
170 additions
and
225 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { useState } from 'react'; | ||
|
||
const CodeExecutor: React.FC = () => { | ||
const [code, setCode] = useState<string>(''); | ||
const [output, setOutput] = useState<string>(''); | ||
|
||
const executeCode = () => { | ||
try { | ||
const result = eval(` | ||
(function() { | ||
${code} | ||
})() | ||
`); | ||
setOutput(String(result)); | ||
} catch (error) { | ||
setOutput(`Erreur : ${(error as Error).message}`); | ||
} | ||
}; | ||
|
||
return ( | ||
<div style={{ padding: '20px', maxWidth: '600px', margin: '0 auto' }}> | ||
<h2>Execute your JavaScript Code</h2> | ||
<textarea | ||
value={code} | ||
onChange={e => setCode(e.target.value)} | ||
placeholder="Write your JavaScript code here..." | ||
rows={10} | ||
style={{ width: '100%', marginBottom: '10px' }} | ||
></textarea> | ||
<button onClick={executeCode} style={{ padding: '10px 20px' }}> | ||
Execute the code | ||
</button> | ||
<div style={{ marginTop: '20px', padding: '10px', backgroundColor: '#f5f5f5' }}> | ||
<h3>Result :</h3> | ||
<pre>{output}</pre> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CodeExecutor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.