Skip to content

Commit e52b610

Browse files
committed
functional code preview
1 parent 9c5d3b9 commit e52b610

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

app/src/components/bottom/CodePreview.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@ const CodePreview: React.FC<{
2424
}> = ({ theme, setTheme }) => {
2525

2626

27-
28-
2927
const ref = useRef<any>();
3028
const iframe = useRef<any>();
31-
const [input, setInput] = useState('');
32-
33-
29+
3430

3531
const startService = async () => {
3632
ref.current = await esbuild.startService({
@@ -49,6 +45,10 @@ const CodePreview: React.FC<{
4945
const currentComponent = state.components.find(
5046
(elem: Component) => elem.id === state.canvasFocus.componentId
5147
);
48+
const [input, setInput] = useState(currentComponent.code);
49+
50+
console.log('this is state', state.components)
51+
console.log('currentcomponent.code', currentComponent.code)
5252

5353

5454
const handleCodeSnipChange = (val) => {
@@ -64,8 +64,8 @@ const CodePreview: React.FC<{
6464
}, [height])
6565

6666
useEffect(() => {
67-
console.log('hello')
68-
}, [currentComponent.code])
67+
setInput(currentComponent.code)
68+
}, [state])
6969

7070

7171
const handleChange = (data) => {

0 commit comments

Comments
 (0)