ReactJS update a component stored in state array

I’m pretty new to coding so I hope my question won’t sound too ridiculous. I’ve spent days to figure something out but didn’t find anything.
So I have a react page with a main component that is my “planning container”.
In this component, I have a child component that represent a whole month. it’s a table with a line for each people and my team, and a td that represents each day of the month.
This child is stored in a variable array that is store in the state.
When I click on a button, I create another child (for the next month), that I will push into the array stored in the state.

I have a variable called “refresh” that just setRefresh(!refresh). This variable is passed to the childs components and I put this variable in the useEffect [] that will trigger a re-render.
=> The problem is that it doesn’t re render at all.

So, just for you to know, I really need to be able to “append” a whole month at each click on the button. I really need this “view” to be able to work.
I will paste some code to make you understand the main idea.

here is the parent :

import React, {useEffect, useState} from "react";
import PlanningMonthBuild from "./PlanningMonthBuild";
import './Planning.css';
import "react-datepicker/dist/react-datepicker.css";

const PlanningBuild = () => {
    const [startForNextMonth, setStartForNextMonth] = useState(new Date());
    const [inputList, setInputList] = useState([]);
    const [refresh, setRefresh] = useState(false);

    useEffect(() => {
        initPlanning();
    }, []);

const handleRefresh = () => {
        setRefresh(!refresh);
    }

    const initPlanning = () => {
        let date = new Date(startForNextMonth.getFullYear(), startForNextMonth.getMonth(), 1);
        let newPlanning = [...inputList];
        newPlanning.splice(0, 0, <PlanningMonthBuild key={'current' + new Date().toISOString()} startDate={date}
                                                     refresh={refresh}/>);
        let date2 = new Date(startForNextMonth.getFullYear(), startForNextMonth.getMonth() + 1, 1);
        date2.setMonth(date.getMonth() + 1);
        setStartForNextMonth(date2);
        setInputList(newPlanning);
    };

    const addOneMonthNext = () => {
        setInputList(inputList.concat(<PlanningMonthBuild key={new Date().toISOString()} startDate={startForNextMonth}
                                                          refresh={refresh}/>));
        let date = startForNextMonth;
        date.setDate(1);
        date.setMonth(date.getMonth() + 1);
        setStartForNextMonth(date);
    };

    return (
        <main>
            <div className="refresh-div" onClick={handleRefresh}><i className="fa fa-refresh" aria-hidden="true"></i></div>
            <button className="myButton" onClick={addOneMonthNext}>Add Next Month</button>
            <div id="insideDiv">
                {inputList}
            </div>

        </main>
    );
};

export default PlanningBuild;

And here is the child (that build each month) :

    import React, {useEffect, useState} from "react";
import useAxiosPrivate from "../hooks/useAxiosPrivate";
import {getFirstDayOfMonth} from "../utils/dates";

const PlanningMonthBuild = ({   startDate,
                                refresh
                            }) => {
    const [dateDebut] = useState(startDate);
    const [jsListe, setJsListe] = useState([]);
    const axiosPrivate = useAxiosPrivate();

    useEffect(() => {
        let isMounted = true;
        const controller = new AbortController();

        try {
            axiosPrivate.get('api/planning/team?start=' + getFirstDayOfMonth(dateDebut.getFullYear(), dateDebut.getMonth()), {
                signal: controller.signal
            }).then(response => {
                if (isMounted) {
                    const newListeJS = response.data;
                    setJsListe(newListeJS);
                }

            });

        } catch (err) {

        }
        return () => {
            isMounted = false;
            controller.abort();
        }

    }, [refresh])

    return (jsListe.map((day)=> {
        ///.... building a table(tr,td...)
    }))

}

export default PlanningMonthBuild;

So, when I put my child component directly into the parent return, it works when I click on refresh button (if my work mate update something for example…), it will update my table but if I store my child component in the array in “inputList” state it doesn’t…

I hope you can understand what I mean.

Thanks in advance for any help.

ReactJS Node and Axios :No ‘Access-Control-Allow-Origin’ header is present on the requested resource

I’m learning programming now so forgive me for any mistakes, I’ll be grateful for any tips.
I have an API that is hosted in the following domain (“api-myapp.com”) and I’m trying from my localhost where I’m creating my front-end to post a form (which only logged in users can send) using axios , but the request takes a long time to complete and when it completes it returns the following error (No ‘Access-Control-Allow-Origin’ header is present on the requested resource.)
(net::ERR_FAILED 504), I’ve tried some solutions I found on the internet but none seem to have worked, this is my code:

FrontEnd:

 try {
        const response = await axios.post('/alunos/', {
            nome,sobrenome,idade,sangue,varinha,patrono,house,sala,
        });
        toast.success('Cadastrado com sucesso');
        console.log(response);
    } catch (e) {
        console.log(e);
        const errors = get(e, 'response.data.errors', []);
        errors.map((error) => toast.error(error));
    }

When you logged in

 try {
    const response = yield call(axios.post, '/tokens', payload);
    yield put(actions.loginSuccess({ ...response.data }));
    axios.defaults.headers.Authorization = `Bearer ${response.data.token}`;
    toast.success('Login realizado com sucesso!');
    payload.navigate('/dashboard');
}

BackEnd

class App {
  constructor() {
    this.app = express();
    this.middlewares();
    this.routes();
  }

  middlewares() {
    this.app.use(cors({ origin: '*' }));
    this.app.use(helmet({ crossOriginResourcePolicy: false }));
    this.app.use(express.urlencoded({ extended: true }));
    this.app.use(express.json());
    this.app.use('/images/', express.static(resolve(__dirname, '..', 'uploads', 'images')));
  }

  routes() {
    this.app.use('/', homeRoutes);
    this.app.use('/prof', profRoutes);
    this.app.use('/tokens', tokenRoutes);
    this.app.use('/alunos', alunoRoutes);
    this.app.use('/casas', casaRoutes);
    this.app.use('/provas', provaRoutes);
    this.app.use('/materias', materiaRoutes);
    this.app.use('/salas', salaRoutes);
    this.app.use('/fotosAlunos', fotoAlunoRoutes);
    this.app.use('/fotosProf', fotoProfRoutes);
  }
}

How to add a click handler with a modifier to vue-draggable (without triggering choose event)

I am trying to implement a click handler on the child of the <draggable> element. I only want the handler to be called if a modifier (alt/ctrl) is used, and I don’t want the choose event to be called if the click handler is called with a modifier.

  <draggable @choose="chooseEvent">
    <child-element
       @click.native.alt.exact.stop="toggleProblem"
       @click.native.ctrl.exact.stop="toggleProblem" />
   ....

This does not work. The handlers are correctly called when their modifiers are used, however, the chooseEvent is always called. If I make the choose event @choose.exact that doesn’t work either. I have also tried adding .stop and .prevent to the click handlers, doesn’t work either.

JavaScript color counter

Okay, so I’m just playing around, however,

<!DOCTYPE html>
<html>
<head>
        <meta charset="utf-8">
        <title>Color Preference</title>
        <link rel="stylesheet" type="text/css" href="css-attempt.css">
</head>
<body>
        <div class="main-div">
                <div class="inner-div">
                        <h2 class="color">I would rather see the color......</h2>
                        <ul>
                                <li>
                                        <input type="radio" name="answer" id="ans1" class="answer">
                                        <label for="ans1" id="option1"> GREEN</label>
                                </li>

                                <li>
                                        <input type="radio" name="answer" id="ans2" class="answer">
                                        <label for="ans2" id="option2"> RED</label>
                                </li>

                                <li>
                                        <input type="radio" name="answer" id="ans3" class="answer">
                                        <label for="ans3" id="option3"> BLUE</label>
                                </li>

                                <li>
                                        <input type="radio" name="answer" id="ans4" class="answer">
                                        <label for="ans4" id="option4"> YELLOW</label>
                                </li>
                        </ul>
                        <button id="submit">submit</button>
                        <div id="showResult" class="colorsArea"></div>
                </div>
        </div>
        <script src="javascript-attempt.js"></script>
</body>
</html>
const colorDB = [
        {
                question: "Color of your next CAR",
                a: "GREEN",
                b: "RED",
                c: "BLUE",
                d: "YELLOW",
                ans: "ans1"
        },
        {
                question: "Color of your next HOME",
                a: "GREEN",
                b: "RED",
                c: "BLUE",
                d: "YELLOW",
                ans: "ans2"
        },
        {
                question: "Color you would paint your KITCHEN",
                a: "GREEN",
                b: "RED",
                c: "BLUE",
                d: "YELLOW",
                ans: "ans3"
        },
        {
                question: "Color you would paint your BATHROOM",
                a: "GREEN",
                b: "RED",
                c: "BLUE",
                d: "YELLOW",
                ans: "ans4"
        }
        {
                question: "Color you would paint your BATHROOM",
                a: "GREEN",
                b: "RED",
                c: "BLUE",
                d: "YELLOW",
                ans: "ans5"
        }
        {
                question: "Color you would paint your BATHROOM",
                a: "GREEN",
                b: "RED",
                c: "BLUE",
                d: "YELLOW",
                ans: "ans6"
        }
        {
                question: "Color you would paint your BATHROOM",
                a: "GREEN",
                b: "RED",
                c: "BLUE",
                d: "YELLOW",
                ans: "ans7"
        }

];

const option = document.querySelector('.option');
const option1 = document.querySelector('#option1');
const option2 = document.querySelector('#option2');
const option3 = document.querySelector('#option3');
const option4 = document.querySelector('#option4');
const option5 = document.querySelector('#option5');
const option6 = document.querySelector('#option6');
const option7 = document.querySelector('#option7');
const submit = document.querySelector('#submit');

const answers = document.querySelectorAll('.answer');
const showResult = document.querySelector('#showResult');

let colorCount = 0;
let color = 0;
const colorOptions = () =>{
                const colorChoice = colorDB[colorCount];
                color.innerText = colorChoice.option;
                option1.innerText = colorList.a;
                option2.innerText = colorList.b;
                option3.innerText = colorList.c;
                option4.innerText = colorList.d;
                option5.innerText = colorList.e;
                option6.innerText = colorList.f;
                option7.innerText = colorList.g;
}
let colorOption = document.querySelector("'#option1'");
let colorOption = document.querySelector("'#option2'");
let colorOption = document.querySelector("'#option3'");
let colorOption = document.querySelector("'#option4'");
let colorOption = document.querySelector("'#option5'");
let colorOption = document.querySelector("'#option6'");
let colorOption = document.querySelector("'#option7'");
let CountColorOptionClicks = 0;

colorOption.addEventListener("click", function() {
    if("option1")
    CountColorOptionClicks += 1;
    console.log(CountColorOptionClicks);
    else if("option2")
        CountColorOptionClicks += 1;
        console.log(CountColorOptionClicks);
    else if("option3")
        CountColorOptionClicks += 1;
        console.log(CountColorOptionClicks);
    else if("option4")
        CountColorOptionClicks += 1;
        console.log(CountColorOptionClicks);
    else if("option5")
        CountColorOptionClicks += 1;
        console.log(CountColorOptionClicks);
    else if("option6")
        CountColorOptionClicks += 1;
        console.log(CountColorOptionClicks);
    else if("option7")
        CountColorOptionClicks += 1;
        console.log(CountColorOptionClicks);
});

colorOptions();

const getCheckAnswer = () =>{
                let answer;
                answers.forEach((curAnsElem) => {
                        if (curAnsElem.checked) {
                                answer = curAnsElem.id;
                        }
                });
                return answer;
};
const deselect = () =>{
        answers.forEach((curAnsElem) => curAnsElem.checked = false);
}

submit.addEventListener('click', () => {
                const checkedAnswer = getCheckAnswer();
                console.log(checkedAnswer);

                if (checkedAnswer === colorDB[colorCount].ans){
                        colors++;
                };
                colorCount++;
                deselect();
                if (colorCount < colorDB.length){
                        colorOptions();
                }
                else{
                        showResult.innerHTML = `
                                <h3>You have choose ${colors}/${colorDB.length}the most...&#9996;</h3>
                                <button class="btn" onclick="location.reload()">Play Again</button>
                        `;
                        showResult.classList.remove('colorsArea');
                }
});

const btn = document.getElementById('btn');

btn.addEventListener('click', function onClick(event) {
    const box = document.getElementById('option1');
            box.style.backgroundColor = 'green';
    const box = document.getElementById('option2');
            box.style.backgroundColor = 'red';
    const box = document.getElementById('option3');
            box.style.backgroundColor = 'blue';
    const box = document.getElementById('option4');
            box.style.backgroundColor = 'yellow';
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro&display=swap');
*{
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        font-weight: 300;
        font-family: 'Source Sans Pro', sans-serif;
}
html {
        font-size: 62.5%;
}
.main-div {
        width: 100vw;
        min-height: 100vh;
        display: grid;
        place-items: center;
        background-color: hsl(10, 10%, 10%);
} 
.inner-div{
        width: 50vw;
        background-color: #F0F9F9 ;
        padding: 4rem 8rem;
        border-radius: 10px;
        box-shadow: 0 10px 10px -3px rgba(0, 0, 0, 0.4);
}
.inner-div h2{
        font-size: 35px;
        font-weight: 500;
        margin: 20px 0 30px 0;
}
.inner-div li{
        font-size: 20px;
        margin-top: 15px;
        list-style: none;
}
input{
        cursor: pointer;
}
input[type="radio"]{
        height: 15px;
        width: 15px;
}

#submit, .btn{
        padding: 10px 30px;
        outline: none;
        font-size: 20px;
        font-weight: 400;
        display: block;
        margin: auto;
        border: none;
        text-transform: uppercase;
        color: #fff;
        background-color: #001122;
        margin-top: 40px;
        cursor: pointer;
        border-radius: 10px;
}
#submit:hover{
        background-color: #afa441;
}
#showResult {
        background-color: #B6BCBD;
        margin-top: 30px;
        padding: 30px 40px;
        box-shadow: 0 10px 10px -3px rgba(0, 0, 0, 0.4);
}
#showResult h3{
        font-size: 35px;
        text-align: center;
}
#showResult .btn{
        margin-top: 20px;
        background-color: #7F3FF1;
        color: #fff;
}
#showResult .btn:hover{
        background-color: #790CA2;
        color: #F8F0FB ;
}
.colorArea{
        display: none;
}

I’m trying to create a case where the user can choose a color and the average of choices will be returned at the end of the session. I also have something in there that should change the background depending on the previous choice made. Any ideas on how to make this operable and better.

Iterator Only Repeating Its Max Potential Value in Nested For Loop (Office Scripts)

I’m using Power Automate & Office Scripts to build a way to do batch creates in Excel. Essentially a way to send an array of values to a script in Excel that then updates an Excel table with all the values in the array. Office Scripts use the JavaScript language.

However, I started getting errors in my results where it is just posting duplicates of the last value in the array the flow sends:

batch create duplicates in table

There’s nothing wrong with the cloud flow and I’ve checked the Office Script. The error occurs on the part that generates the new rows in the in-memory table. Specifically this code:

    //-1 to 0 index the RowNum
RowNum = RowNum - 1;
//Iterate through each object item in the array from the flow
for (let i = 0; i < CreateData.length; i++) {
  //Create an empty row at the end of the 2D table array & increase RowNum by 1 for the next line updating that row
  TableData.push(EmptyRow);
  RowNum++;
  //Iterate through each item or line of the current object
  for (let j = 0; j < Object.keys(CreateData[i]).length; j++) {
    //Create each value for each item or column given
    TableData[RowNum][Number(Object.keys(CreateData[i])[j])] = CreateData[i][Object.keys(CreateData[i])[j]];
  }
}

Which is very strange because essentially the same code works for another method of batch create for larger tables where I can’t do things in memory:

    //Iterate through each object item in the array from the flow
for (let i = 0; i < CreateData.length; i++) {
  //Create an empty row at the end of the 2D table array & increase RowNum by 1 for the next line updating that row
  table.addRow()
  RowNum = RowNum + 1
  //Iterate through each item or line of the current object
  for (let j = 0; j < Object.keys(CreateData[i]).length; j++) {
    //Create each value for each item or column given
    TableRange.getCell(RowNum, Number(Object.keys(CreateData[i])[j])).setValue(CreateData[i][Object.keys(CreateData[i])[j]])
  }
}

And similar code works for the a similar process in a batch update script:

    //Iterate through each object item in the array from the flow
for (let i = 0; i < UpdatedData.length; i++) {
  //If the record's Primary Key value is found continue, else post to error log
  if (ArrayPK.indexOf(UpdatedData[i].PK) > 0) {
    //Get the row number for the line to update by matching the foreign key from the other datasource to the primary key in Excel
    RowNum = ArrayPK.indexOf(UpdatedData[i].PK)

    //Iterate through each item or line of the current object
    for (let j = 0; j < Object.keys(UpdatedData[i]).length - 1; j++) {
      //Update each value for each item or column given
      TableData[RowNum][Number(Object.keys(UpdatedData[i])[j])] = UpdatedData[i][Object.keys(UpdatedData[i])[j]]
    }
  }

And I’m not seeing anything logically wrong with it.

In fact, if I change out the i reference in the code for a static number so it references the same item each time, then it duplicates the values at that other static row index. It’s as if in this specific case when the i reference is in a nested loop, it is just going to the last value in the array of values I pass it from Power Automate (usually the maximum value i will ever have in this loop) and never changing from that value in each loop run even though each run should add one to i (i++).

Why is this happening?

How does NestJS match the injection target and the injected instance?

According to the NestJS official document [1], it describes “In Nest, thanks to TypeScript capabilities, it’s extremely easy to manage dependencies because they are resolved just by type.”

I’m very confused of this description, because at runtime we do not have any type information of the constructor argument which is erased during the transpilation.

How NestJS actually resolves the matching between the required type (class) and the actual object (instance)?

Laravel PDF blank after using foreach loop for building items inside

I use a stored procedure to send data to a pdf template, after that, I loop the JSON in a for-each to build the items inside the pdf, this procedure works fine in local, however, the pdf returns blank after I try this procedure in production on a remote server.

This is my method inside the controller to get my JSON and send it to the pdf.

    public function generarFichaPago(Request $request)
{
    $datosPDF = DB::select('exec SP_GenerarPDF @Op = ?, @matricula = ?, @ciclo = ?, @mes = ?', ['fichaPago', $request->matricula, $request->ciclo, $request->mes]);
    $pdf = PDF::loadView('Oficios.FichaPagoInsc', compact('datosPDF'))->setPaper('a4');
    $path = public_path('pdf/');
    $fileName =  time().'.'. 'pdf' ;
    $pdf->save($path . '/' . $fileName);
    $pdf = public_path('pdf/'.$fileName);
    return response()->download($pdf);
}

This is inside my PDF template where I want to show the data.

<div class="container">
    @foreach ($datosPDF as $dato)
    <div id="n1" class="cell">
        {{-- <img src="{{ asset('images/logo_bbva.jpg') }}" width="105" height="105"> --}}
        Num. CIE: XXXXXXXXXXX
    </div>
    <div id="n2" class="cell">
        <ul style="list-style-type:none;">
            <li>Alumno: <strong>{{$dato->MATRICULA}} {{$dato->NOMBRE_P}}</strong></li>
            <li>Ciclo Escolar: <strong>{{$dato->CICLO}}</strong></li>
            <li>Nivel: <strong>{{$dato->SECCION}}</strong></li>
            <li>Grado: <strong>{{$dato->GRADO}}°</strong></li>
        </ul>
        <div id="leyenda">
            <strong style="color: blue">Pago Inscripción Ciclo {{$dato->CICLO}}</strong>
        </div>
    </div>
    <div id="n3" class="cell">
        <br>
        <ul style="list-style-type:none;">
            <li>Referencia: <strong>1234567890</strong></li>
            <li>Vigencia Al: <strong>{{$dato->FECHA_LIM}}</strong></li>
            <li>Importe: <strong>{{$dato->IMP_PAG}}</strong></li>
        </ul>
    </div>
    <div id="n4" class="cell">
        <p>___________ FIRMA</p>
    </div>
    @endforeach
</div>

This whole procedure works fine a generates the pdf correctly in local, like this. enter image description here

But when I try this on production in a remote server the pdf return blank, like this.enter image description here

I’m not sure what the error is in this instance, since the controller and template are identical, and the information inside the JSON is also the same, so both pdf should show the same info but one generates a blank pdf.

How to pass Django formset form variable to JavaScript function

Basically I am using formsets, each form has a form ID and a deleted button amongst other things.
When the delete button is clicked i’d like to call a function and pass the form ID to it, how can i achieve this?

{% for form in formset %}

{{ form.form_id_test }}

<button id="delete-form" type="button" class="btn btn-primary mb-2" 
onclick="deleteFormFunc({{ form.form_id_test }})">
    Delete Form
</button>

{% endfor %}

I am not able to pass the arguments like this, basically syntax error.

How do I reorder my HTML Divs in JS and have their child elements follow?

In my code,I am trying to rearrange an array of parent divs and their children into a descending order, based on the value within the parent, and display it in the DOM. Is there an “if else statement” I could you use to reach in and accomplish this task? I am pushing number values into the parent div from an input field, I am then grabbing those values from the parent and forcing them into an array, and ordering that array. After that, I would like to append the values back into DOM with their respective children elements, though I don’t know how to. Any help is appreciated.
Here is my code:
HTML

<!DOCTYPE html>
<html>
<head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>Order Divs</title>
      <link rel="stylesheet" href="style.css">
</head>
<body>
  <input type="number" id="point-input">
  <button id="sub-btn">Submit</button>
    <button id=order>Order Button</button>
    <button id="add-btn">Add</button>
    <div id="container"></div>
    <script src="main.js"></script>
</body>
</html>

Javascript

//variables below

let orderBtn=document.getElementById("order")
console.log(orderBtn)

let addBtn=document.getElementById("add-btn")
console.log(addBtn)

const container=document.getElementById("container")
console.log(container)


let numArr=[]

let numInc=1

let numToBeRe=[]

let child=document.getElementsByClassName(`child${numInc}`)
console.log(`child${numInc}`)

let subBtn=document.getElementById("sub-btn")
console.log(subBtn)

let pointInput=document.getElementById("point-input")
console.log(pointInput)

//adding an event listener to the submit button below 

subBtn.addEventListener("click",()=>{
let pointInput=document.getElementById("point-input")   
    console.log(pointInput.value)
        numToBeRe.push(pointInput.value) //push the input field value to an array
            console.log(numToBeRe)
//              console.log(typeof(pointInput.value))
                    pointInput=parseInt(pointInput.value) 
                        //console.log(typeof(pointInput))
                                            //numArr.push(pointInput);
                                            //console.log(numArr);
                                        let hp=0;
                                        let name="";
                                        let weapns="";

                                    //Adding html literals on the onclick

        container.innerHTML+=
        `<div class="child${numInc} child">${pointInput}
            <div class="the-inner-container">
                <div class="name-display"></div>
                    <input class="name-imput">
                    <button class="name-sub-btn">Submit</button>

                    <div class="hp-display"></div>
                    <input class="hp-input">
                    <button class="hp-sub-btn">Submit</button>


                    <div class="weapons-display"></div>
                    <input class="weapons-input">
                    <button class="weapons-sub-btn">Submit</button>








            </div>
        </div>`

                                    console.log(`child${numInc}`)           
                                empty()

// Name variables per container
let nameBtn=document.querySelector(".name-sub-btn")
console.log(nameBtn)

let nameInput=document.querySelector(".name-input")
console.log(nameInput)

let nameDisplay=document.querySelector(".name-display")
console.log(nameDisplay);

nameBtn.addEventListener("click",()=>{
    nameDisplay.innerText=nameInput.value
    nameInput.value="";
})


console.log(childOfCont)
})






function empty(){
    document.getElementById("point-input").value="";    // empty the input field after a submit
}

const childOfCont=document.getElementsByClassName("child")
console.log(childOfCont)

orderBtn.addEventListener("click",()=>{
        const fixed=Array.from(childOfCont) // make an array from the containers direct children
            console.log(fixed)

                for(let i=0;i<fixed.length;i++) 
                    {console.log(fixed[i]) //loop over the arrays elements 

                    numToBeRe.sort(function(a,b){return b-a})  //sort the through the iniative numbers and rearrange them in descending order
                            console.log(numToBeRe)


                                    // console.log the increments
                                

                            fixed[i].innerText=""; //empty out the inner text of the childOfCont divs
                        fixed[i].append(numToBeRe[i])//add the iniative numbers into the fixed divs
        console.log(fixed[i])


        
        
}});

Docusaurus font loading for text but not headings

In my Docusaurus custom CSS file I have this code:

    @import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap");
:root {
    --ifm-color-primary: #25c2a0;
    --ifm-color-primary-dark: #29784c;
    --ifm-color-primary-darker: #277148;
    --ifm-color-primary-darkest: #205d3b;
    --ifm-color-primary-light: #33925d;
    --ifm-color-primary-lighter: #359962;
    --ifm-color-primary-lightest: #3cad6e;
    --ifm-code-font-size: 95%;
    --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
    font-family: "Montserrat", sans-serif;
}

This code is changing the regular text on my site, but it isn’t changing headings. When I inspect the headings I see that the Montserrat font is crossed out, indicating that it is being overridden somewhere. Are heading styles set anywhere by default with Docusaurus?

Convert this into a single player game against the computer?

I am creating this tic-tac-toe game and have pretty much completed it for a 2-player version. Now I am attempting to create a single player game in which the computer makes moves against you automatically. Any suggestions?

I am not looking for the computer to be super smart or anything. I just want it so that after myself or whoever uses the site clicks a cell, the computer’s move randomly occurs after.

`

let gameState = {
  player1: null,
  player2: null,
};

let gameOver = false;

//define the players
const player_1_Text = "X";
const computer = "O";
let currentPlayer;

//Dom References
const text1 = document.getElementById("p1");
const text2 = document.getElementById("p2");
const button1 = document.getElementById("button1");
const output1 = document.getElementById("output1");
const output2 = document.getElementById("output2");

const boxes = Array.from(document.getElementsByClassName("cell"));
const title = document.getElementById("title");
const playAgainButton = document.getElementById("playAgainButton");
const submit = document.getElementById("submit");
const spaces = [];

const renderBoard = () => {
  boxes.forEach((box, index) => {
    let styleString = "";
    if (index < 3) {
      styleString += `border-bottom: 3px solid var(--orange);`;
    }
    if (index % 3 === 0) {
      styleString += `border-right: 3px solid var(--orange);`;
    }
    if (index % 3 === 2) {
      styleString += `border-left: 3px solid var(--orange);`;
    }
    if (index > 5) {
      styleString += `border-top: 3px solid var(--orange);`;
    }
    box.style = styleString;
    box.addEventListener("click", cellClicked);
  });
};

function display1() {
  output1.innerHTML = text1.value;
}

function display2() {
  output2.innerHTML = text2.value;
}

// Clicked Cell
function cellClicked(e) {
  const id = e.target.id;
  if (!spaces[id]) {
    spaces[id] = currentPlayer;
    e.target.innerHTML = currentPlayer;

    if (playerHasWon()) {
      title.innerHTML = `${currentPlayer} has won!`;
      return;
    }

    if (draw()) {
      title.innerHTML = `It's a tie!`;
      console.log(`Tie Game`);
      return;
    }

    //change players

    currentPlayer =
      currentPlayer === player_1_Text ? player_2_Text : player_1_Text;
  }
}

//How a player can win
function playerHasWon() {
  if (spaces[0] === currentPlayer) {
    if (spaces[1] === currentPlayer && spaces[2] === currentPlayer) {
      console.log(`${currentPlayer} wins!`);
      return true;
    }
    if (spaces[3] === currentPlayer && spaces[6] === currentPlayer) {
      console.log(`${currentPlayer} wins!`);
      return true;
    }
    if (spaces[4] === currentPlayer && spaces[8] === currentPlayer) {
      console.log(`${currentPlayer} wins!`);
      return true;
    }
    renderBoard();
  }
  if (spaces[8] === currentPlayer) {
    if (spaces[2] === currentPlayer && spaces[5] === currentPlayer) {
      console.log(`${currentPlayer} wins!`);
      return true;
    }
    if (spaces[6] === currentPlayer && spaces[7] === currentPlayer) {
      console.log(`${currentPlayer} wins!`);
      return true;
    }
    renderBoard();
  }
  if (spaces[4] === currentPlayer) {
    if (spaces[1] === currentPlayer && spaces[7] === currentPlayer) {
      console.log(`${currentPlayer} wins!`);
      return true;
    }
    if (spaces[3] === currentPlayer && spaces[5] === currentPlayer) {
      console.log(`${currentPlayer} wins!`);
      return true;
    }
    if (spaces[2] === currentPlayer && spaces[6] === currentPlayer) {
      console.log(`${currentPlayer} wins!`);
      return true;
    }

    renderBoard();
  }
}
//enter tie function here
function draw() {
  let tie = 0;
  spaces.forEach((space, index) => {
    if (spaces[index] !== null) tie++;
  });
  if (tie === 9) {
    title.innerHTML = `It's a tie!`;
    playAgain();
  }
}

function playAgain() {
  spaces.forEach((space, index) => {
    spaces[index] = null;
  });
  boxes.forEach((box) => {
    box.innerHTML = "";
  });
  title.innerHTML = `Let's Play!`;
  currentPlayer = player_1_Text;
}

//event listeners
button1.addEventListener("click", display1);
button1.addEventListener("click", display2);
playAgainButton.addEventListener("click", playAgain);
playAgainButton.addEventListener("click", function (e) {});

playAgain();
renderBoard();`

Can’t read ‘id’ when Uppy component is rendered

I created this component :

// Data is an `useRef`
const SelectImage = ({ data }) => {
    const uppy = new Uppy({
        id: 'uppy',
        autoProceed: true,
        restrictions: {
            maxFileSize: 10485760,
            maxTotalFileSize: 104857600,
            maxNumberOfFiles: 1000,
            allowedFileTypes: ['.jpg', '.jpeg', '.png']
        }
    })
        .use(DropTarget, { id: 'DropTarget', target: document.body })
        .use(Compressor, { id: 'Compressor' })

    uppy.on('complete', files => {
        data.current = { files }
    })

    return (
        <Dashboard
            uppy={uppy}
            disableStatusBar={true}
            proudlyDisplayPoweredByUppy={false}
            theme='light'
        />
    )
}

With React Scripts 5.0.1, React 18.2.0 and Uppy Core 2.3.1, Uppy React 2.2.2, Uppy Compressor 0.3.0 and Uppy Drop Target 1.1.3.

When the component above is rendered, the following error is thrown:

Dashboard.js:1121 Uncaught TypeError: (0 , _nonSecure.nanoid) is not a function
    at new Dashboard (Dashboard.js:1121:1)
    at Uppy.use (Uppy.js:1012:1)
    at Dashboard.installPlugin (Dashboard.js:49:1)
    at Dashboard.componentDidMount (Dashboard.js:19:1)
    at commitLayoutEffectOnFiber (react-dom.development.js:23305:1)
    at commitLayoutMountEffects_complete (react-dom.development.js:24688:1)
    at commitLayoutEffects_begin (react-dom.development.js:24674:1)
    at commitLayoutEffects_begin (react-dom.development.js:24656:1)
    at commitLayoutEffects (react-dom.development.js:24612:1)
    at commitRootImpl (react-dom.development.js:26823:1)

Uncaught TypeError: Cannot read properties of undefined (reading 'id')
    at Uppy.removePlugin (Uppy.js:1081:1)
    at Dashboard.uninstallPlugin (Dashboard.js:61:1)
    at Dashboard.componentWillUnmount (Dashboard.js:36:1)
    at callComponentWillUnmountWithTimer (react-dom.development.js:22852:1)
    at safelyCallComponentWillUnmount (react-dom.development.js:22873:1)
    at invokeLayoutEffectUnmountInDEV (react-dom.development.js:25188:1)
    at invokeEffectsInDev (react-dom.development.js:27351:1)
    at commitDoubleInvokeEffectsInDEV (react-dom.development.js:27321:1)
    at flushPassiveEffectsImpl (react-dom.development.js:27056:1)
    at flushPassiveEffects (react-dom.development.js:26984:1)

I tried to rollback Uppy, uninstall all the plugins, change the ids values and encapsulate the Uppy instance as it is shown in the documentation example, but nothing worked. Any tips?

Proper variable name for find method [closed]

I’m Japanese web developer. I’m currently thinking about the proper variable name for the result from javascript find method. I would rather not use “result” because it is too simple and it’s hard to understand what’s inside. Does anyone have any idea?

const targetChar = 'someName1';

let arrayOfObj = [
  {
    name: 'someName1',
    age: 38
  },
  {
    name: 'someName2',
    age: 24
  }
];

const result = arrayOfObj.find((obj) => {
  return obj.name === targetChar;
});

console.log(result);

Beginner wanting to create a hidden windows app [closed]

Just looking for some pointers as to what language I should use and what free sources/editor to use/focus on. The bold text is what I am trying to do – the rest is context (sorry)

I have very little experience with javascript (some GoogleSheets), but am wanting to also learn python. I am currently working my way through the freecodecamp courses, but only just started.

To assist with keeping a log of what I am working on throughout the day, I have downloaded a free screen capture program by Gavin Kendall. I have it set up to take a screenshot every 3 minutes and it works great. It stores an image of the active window and also the screen (or multiple). This program also compares the previous image so that it is not storing multiple versions of the same image. As the clock is constantly changing however, each image will always be different when recording the screen. I want to create an app that will turn off the clock in the taskbar if the cursor/mouse is inactive for x minutes and also display icons/options just above the clock location so I can select and display an image of sleeping, a phone or eating so the screenshots let me know why I may have been inactive at a particular time.

I eventually found how to turn off the clock. Right clicked the time, selected taskbar settings – in the notification area, select turn system icons on or off. The clock should be there. It wasn’t at first for me, but after selecting windows i and searching for systems icons, it was.

So what I would like some guidance on is which language would be able to achieve the above and have it run in the system tray? Or should I be looking at something else to achieve this? Probably not the best project for a beginner, but I would like to give it a go. Thanks.