#Light to Dark

2 messages · Page 1 of 1 (latest)

wild blaze
#
import React from "react"
import Navbar from "./components/Navbar"
import Main from "./components/Main"


export default function App() {
    
    const [darkMode, setDarkMode] = React.useState(true)

    function toggleDarkMode() {
        setDarkMode(prevMode => !prevMode)
    }

    return (
        <div className="container">
            <Navbar onClick={toggleDarkMode}/>
            <Main />
        </div>
    )
}

Can someone help me out? All I added was a state and a toggle function to App.js.

https://scrimba.com/learn/learnreact/warm-up-add-dark-light-modes-to-reactfacts-site-co5924409bb476cc78b0d818a?a=1705.0.12.L1_1-20_2

Scrimba

Learn to code with interactive screencasts. Our courses and tutorials will teach you React, Vue, Angular, JavaScript, HTML, CSS, and more. Scrimba is the fun and easy way to learn web development.

unkempt trail
#

console.log() helps a lot, when are seeing unexpected error, try doing console.log(props) in NavBar and Main component and see what it shows in log.