ProgrammingAccount90

u/ProgrammingAccount90


r/react•

I think I may not know how to mock some of my Contexts... I have a button in my navbar that when clicked styles the page either in dark mode or light mode. The context is called "lightDark" and it is either "light" or "dark". I am mocking the lightDark variable to "light", firing the button and then checking that the class name has changed but it doesn't change.

here is the test

test('button click toggles lightDark from light to dark', async () => {
    const mockSetUser = jest.fn()
    const mockSetLight = jest.fn(() => "dark")

    render (
        <UserContext.Provider value={{username: "Bill", setUsername: mockSetUser}}>
            <LightDarkContext.Prov
20

r/linux4noobs•

I am trying to setup my other monitor on Ubuntu 23.04. When I mirror the screen it works fine but when I try to join them the settings app crashes and it does not work. When I first dual booted my laptop I tested it to make sure the external monitor worked and it did so I went ahead with installing. I am not sure why It doesn't work now.

$ xrandr --query

Screen 0: minimum 16 x 16, current 1920 x 1080, maximum 32767 x 32767
XWAYLAND0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 380mm x 210mm
   1920x1080     59.96*+
   1440x1080     59.99  
   1400x1050     59.98  
   1280x1024     59.89  
   1280x960      59.94  
   1152x864
15

r/webdev•

I have this navbar component

import { useState, useEffect, useContext } from "react";
import { LightDarkContext } from "../context/LightDarkContext";
import Links from "./Navbar-Links";

import light from "../assets/images/light.svg"
import dark from "../assets/images/dark.svg"
import "../assets/styles/components/Navbar.css"

const Navbar = () => {
    const {lightDark, setLightDark} = useContext(LightDarkContext);
    const [active, setActive] = useState("");

    useEffect(() => {
        if (window.location.pathname === "/") {
            setActive("Home")
        } else if (window.location.pathname === "/login")  {
    
11

r/computer_help•

Its a Asus ROG Zephyrus M15 (GU502LW) dual booted with Ubuntu 22.04.2 and Window 11 22H2 (10.0.22621.1555).

Last night it was working just fine but today when I tried to boot it up nothing happened. No red light on the power button, no spool of the cpu fans, nothing. When I hold down power for 30 seconds the CPU fan spools up for a second and then it cuts out. When i had it plugged in the charging light was on but now it wont.

Im planning on taking it to a laptop repair store on monday but id figured id ask if anyone here knew what this could be.

32

r/webdev•

So I am doing a TOP project called wheres waldo. You are supposed to put a character in a crowded picture and find him. I am randomly placing him and using getBoundingClientRect (having problems with this as well) to match up the coordinates of the board picture and the waldo image.

code:

const Game = () => {
    const [posX, setPosX] = useState(0);
    const [posY, setPosY] = useState(0);

    const getRandomCords = (referenceRect, targetRect) => {
        const paddingTop = 300

        let randX = Math.floor(Math.random() * (referenceRect.width - targetRect.width));
        let randY = Math.floor(Math.random() * (referenceRect.height - targetRect.heig
15

r/Firebase•

edit: the title is supposed to read "I am having trouble with Auth function signInWithEmailAndPassword"

​

if I use

<button className="login_btn" onClick={() => signInWithEmailAndPassword(email, password)}>Login</button>

I get this error

Uncaught (in promise) TypeError: can't assign to property "_canInitEmulator" on "[email protected]": not an object
    _performFetchWithErrorHandling index.ts:135
    _performApiRequest index.ts:93
    _performSignInRequest index.ts:198
    signInWithPassword email_and_password.ts:45
    _getIdTokenResponse email.ts:116
    _processCredentialSavingMfaContextIfNecessary mfa_error.ts:71
    _signInWithCredential cred
22

r/theodinproject•

I am on the firebase project where’s waldo right now. They are making you use firebase to use a db and to host. My question is why cant we use something like SQL or sqlite? Do they ever cover a legit backend with routing?

Before this course I was making projects with Flask and was under the impression thats how real websites were made. Is that ever going to be covered?

52

r/webdev•

I am testing a component called links which if props.alt === "Cart" renders the component with 1 additional element within it called .Cart-Num which displays the number of items within their cart. When I try to test it I am passing the value along with the provider but it is not displaying the correct textContent.

Nav-Links.js

const Links = ({name, alt, path, id}) => {
    
    const {cartItemCount} = useContext(UserContext);

    return (
        <div id={id} name={alt}>
            {alt !== "Cart" ? (
                <Link to={path}>
                    <img className="svg" src={name} alt={alt}></img>
                    {alt}
               
13

r/battlefield2042•

I made it run as admin and even tried to re download it and nothing. All my drivers are up to date as well. When I log into to EA it gives me a 500 error and to try back later. I tried restarting the app and my computer a few times with no changes. Is anyone else having this problem?

27

r/webdev•

I need to pass const [user, setUser] = useState(null); from RouteSwitch.js down a couple depths to a component called signUp.js

here is RouteSwitch.js

import React, { createContext, useState } from "react"
import { BrowserRouter, Route, Routes } from "react-router-dom";
import App from "./App"
import Store from "./Store";

export const UserContext = createContext();

export const RouteSwitch = () => {

    const [user, setUser] = useState(null);

    return (
        <BrowserRouter>
            <Routes>
                <UserContext.Provider value={{user, setUser}}>
                    <Route path=
04


r/webdev•

I am brand new to React and taking The Odin Project. I am doing an assignment where I need to create a CV website. Assignment here: https://www.theodinproject.com/lessons/node-path-javascript-cv-application

So I have a title section of my page and when you hover over it a "edit" button appears. When you click on it it opens a popup form that I would like to display input fields with the correct fields. Problem is I don't know how to pass the values from <Top/> to <Form/>. Here is the codepen and I hope It conveys my question a little more clearly.

[https://codepen.io/kalivm90/pen/VwGbpvr](https://cod

24