File tree 2 files changed +20
-6
lines changed
2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,12 @@ let make = (~logs, ~setLogs) => {
22
22
23
23
<div >
24
24
{switch logs {
25
- | [] => React .null
25
+ | [] =>
26
+ <div className = "m-2" >
27
+ {React .string (
28
+ "Add some 'Console.log' to your code and enable 'Auto-run' to see your logs here." ,
29
+ )}
30
+ </div >
26
31
| logs =>
27
32
let content =
28
33
logs
Original file line number Diff line number Diff line change @@ -6,22 +6,31 @@ let wrapReactApp = code =>
6
6
7
7
@react.component
8
8
let make = (~compilerState : CompilerManagerHook .state , ~clearLogs , ~runOutput ) => {
9
+ let (validReact , setValidReact ) = React .useState (() => false )
9
10
React .useEffect (() => {
10
11
if runOutput {
11
12
switch compilerState {
12
13
| CompilerManagerHook .Ready ({result : Comp (Success ({js_code }))}) =>
13
14
clearLogs ()
14
15
let ast = AcornParse .parse (js_code )
15
16
let transpiled = AcornParse .removeImportsAndExports (ast )
16
- switch AcornParse .hasEntryPoint (ast ) {
17
- | true => transpiled -> wrapReactApp -> EvalIFrame .sendOutput
18
- | false => EvalIFrame .sendOutput (transpiled )
19
- }
17
+ let isValidReact = AcornParse .hasEntryPoint (ast )
18
+ isValidReact
19
+ ? transpiled -> wrapReactApp -> EvalIFrame .sendOutput
20
+ : EvalIFrame .sendOutput (transpiled )
21
+ setValidReact (_ => isValidReact )
20
22
| _ => ()
21
23
}
22
24
}
23
25
None
24
26
}, (compilerState , runOutput ))
25
27
26
- <EvalIFrame />
28
+ <div className = "m-2" >
29
+ {validReact
30
+ ? React .null
31
+ : React .string (
32
+ "Create a React component called 'App' if you want to render it here, then enable 'Auto-run'." ,
33
+ )}
34
+ <EvalIFrame />
35
+ </div >
27
36
}
You can’t perform that action at this time.
0 commit comments