score:0

import { useAppSelector } from "../../hooks";
import IUser from "../../models/user";

const Header: FC = () => {
    const [btn, setBtn] = useState(false);
    const user: IUser | null = useAppSelector( state => state.user );

    const btn_click = () => {
        setBtn(!btn);
    }
    console.log(user, "user"); // consoles.log( { _id: 2452345, name: "Eldar" } )

    return(
            <div>
            { user ? 
                <button className={ style.header__button } }> { user?.name } </button> :
                <button className={ style.header__button } onClick={ () => btn_click() }> Reg </button> }
            { btn && <ModalWrapper>
                        <SignIn/>
                    </ModalWrapper> }
        </div>
    )
}

export default Header

Related Query

More Query from same tag