Feeling dumb here with toogle trucker in React.jsx

Hello guys, i was trying to complete the challenge from Scrimba tutorial, but it doesn’t apper anything in the screen. Maybe I write something wrong

import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App'

function Index() {
  return (
    <div>
    <App />
 </div> )
}

ReactDOM.createRoot(document.getElementById('root')).render(<Index />); 
import React from 'react'
export default function WindowTracker(){
    return(
        <div>
        <h1>
        Window width {window.innerWidth}
        </h1>
        </div>
    )
}
import React from 'react'
import WindowTracker from './WindowTracker'

export default function App(){
 
 const [show, setShow] = React.useState(true)
 
 function toggle(){
     setShow(prevShow => !prevShow)
 }
 
    <div>
    <button onClick={toggle}>Toggle window: tracker</button>
    {show && <WindowTracker />}
    </div>
}

You are not returning anything inside App (i.e. you are not returning the JSX)

1 Like

thank you so much, lasjorg

1 Like