V
V
Vladimir2020-02-14 04:26:02
JavaScript
Vladimir, 2020-02-14 04:26:02

Why does the application freeze when using this component?

Goodnight. Can you please tell me what can cause the application to hang in this code? UPDATE

not working :

export default function TopBar() {
    return (
        <Router>

            <SelectNavigation />

        </Router>
    )
}

function SelectNavigation() {

    // if (window.innerWidth > 900) {
    //
         return (
            <nav className='nav-computer'>
                <Navigation items={navigationItems}/>
                <div className="logo">
                    <Link to='/'>
                        <div className="first-child">{logo.firstChild}</div>
                        <div className="last-child">{logo.lastChild}</div>
                    </Link>
                </div>
            </nav>
        )
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shohruh Shaimardonov, 2020-02-14
@joeberetta

Because you're using arrow functions that don't bubble up, unlike function. If you swap functions or switch arrows to function, it will work.
Read about hoisting in js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question