form wont export when search (search and export conflict)

I got one form with two submit button.

blade.php

    <form method="GET" id = "uploadForm">
        @csrf

        <div class="form-group">
            <button type="submit" value="Search" class="btn btn-info" id="search_btn" onclick="searchForm()">Search <i class="fa fa-search"></i></button> &nbsp;
            <button type="submit" value="Export" class="btn btn-success float-right" id="export_btn" onclick="exportForm()">Export <i class="fa fa-download"></i></button>
        </div>
    </form>

js file

function searchForm() get data and display as datatable
{
    let form = $('#uploadForm');
    let table = $('.datatable');

    form.attr('action', '/search').submit(function(e) {
        e.preventDefault();

        if ($.fn.DataTable.isDataTable(".datatable")) {
            table.DataTable().clear().destroy();
        }

        table.DataTable({
            processing: true,
            serverSide: true,
            bDestroy: true,
            bJQueryUI: true,
            ajax: {
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                url : form.attr('action'),
                type : form.attr('method'),
                data : {
                    type: $("#type").val(),
                    from: $("#from").val(),
                    to  : $("#to").val(),
                },
            },
            columnDefs: [
                {'data': 'trx_id',      "targets": 0, title: "Trx ID"},
                {'data': 'type',        "targets": 1, title: "Type"},
                {'data': 'sender_id',   "targets": 2, title: "Sender ID"},
                {'data': 'receiver_id', "targets": 3, title: "Receiver ID"},
                {'data': 'amount',      "targets": 4, title: "Amount"},
                {'data': 'remark',      "targets": 5, title: "Method"},
                {'data': 'fee',         "targets": 6, title: "Fees"},
                {'data': 'afterFee',    "targets": 7, title: "Amount After Fees"},
                {'data': 'date',        "targets": 8, title: "Date"},
            ],
            error(){
                alert("error");
            }
        });
        // prevent submit multiple time
        e.stopImmediatePropagation();
        return false;
        // prevent submit multiple time
    });
}

function exportForm() //export data and download excel 
{
    $('#uploadForm').attr('action', '/export');
    $('#uploadForm').attr('target', '_blank').submit();
}

Search_form and export_form both work fine. But it have problem when I call search_form then call export_form, it will always go into search_form and will not download excel. I have run out of idea how to solve this issues.

Is the anyway to solve build error in nextjs?

I am building a site in nextJS. Recently I got an error when I run yarn run dev for building. Which is,

> Build error occurred
Error: Export encountered errors on following paths:
        /[page]/[pid]/[slug]
    at /home/ubu/Desktop/Projects/HexaCom-Final One/HexaCom/node_modules/next/dist/export/index.js:500:19
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Span.traceAsyncFn (/home/ubu/Desktop/Projects/HexaCom-Final One/HexaCom/node_modules/next/dist/trace/trace.js:74:20)
    at async /home/ubu/Desktop/Projects/HexaCom-Final One/HexaCom/node_modules/next/dist/build/index.js:987:17
    at async Span.traceAsyncFn (/home/ubu/Desktop/Projects/HexaCom-Final One/HexaCom/node_modules/next/dist/trace/trace.js:74:20)
    at async /home/ubu/Desktop/Projects/HexaCom-Final One/HexaCom/node_modules/next/dist/build/index.js:861:13
    at async Span.traceAsyncFn (/home/ubu/Desktop/Projects/HexaCom-Final One/HexaCom/node_modules/next/dist/trace/trace.js:74:20)
    at async Object.build [as default] (/home/ubu/Desktop/Projects/HexaCom-Final One/HexaCom/node_modules/next/dist/build/index.js:82:25)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I tried to solve it by adding solutions from the internet like adding log files inside
getStaticProps function. Nothing solving the issue.

Js local user entry [duplicate]

I was trying to make a user entry in local and write this code but always “else”
working even if i write correct info. Can you help me with making this code working ?

var email1 = "[email protected]";
var password1 = "1234";

var eposta = document.getElementById("email");
var sifre = document.getElementById("pass");

function login() {
    if (eposta == email1 && sifre == password1) {
    window.location.href = "products.html";
    alert("Welcome", email1);
    }
    else {
        alert("Wrong e-mail or password")
    }
}

Validation different message on the condition in password?

Hi i would like some help on my password field where i have this 2 type of validation message

first if the input for password when user click on submit button it be display please enter password!

2nd if the input for password is incorrect where it didnt meeet the requirement it display password do not meet the requirement!

Here my code for my html for the password and submit button

                                <div class="form-group row">
                                <label for="validationpassword" class="col-form-label passwordadduser">*Password:</label>
                                <div class="col-6 d-flex">
                                <input name="validationpassword" onChange="onChange()" type="password" class="form-control pass" id="password" placeholder="Password"  required>
                                <i class="bi bi-eye-slash" id="togglePassword"></i>
                                <div style="margin-left: 15px;" class="invalid-tooltip password-empty" hidden>
                                    Enter a password!
                                </div>
                                <div style="margin-left: 15px;" class="invalid-tooltip password-notmeet" hidden>
                                    Password do not meet the requirement!
                                </div>
                                </div>
                            </div>

                        <button type="submit" class="btn-primary submitbutton">Add</button>

I have try a Jquery/JavaScript but seems not working i think i doing something wrong here

var empty = $(document.getElementById("password").value == '')
 if (empty){
 $('.pass').removeAttr('hidden');
 }
 else{

 $('.pass').attr('hidden', '');
 }

needed help as i not familiar with how the input should work ?

why the template ui did not show the vue data

I am a newbie with Vue, now I define the vue code like this:

import Vue from "vue";

export default Vue.extend({
  data: () => {
    message: "show message";
  },
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<template>
  <div id="app">
    <div v-text="message"></div>
  </div>
</template>

why the UI did not show the Vue data message? this is my sandbox version code: https://codesandbox.io/s/loving-sea-snvfj?file=/src/App.vue:149-237

Issue with Javascript in Posting system

So, I have a posting system. When you type a post in the input field and click the submit button, the post displays with the help of PHP and AJAX.

Now on that post are stuff like a like button and comment button, and when you click the like button, it turns blue. Now, after making a post and the post displaying, clicking the like button will make it blue. However, let’s say you make another post. For that post, everything works, except when you click the like button on the second or third post, it makes the like button on the first post only turn blue, similarly with the comment button. Also, the first post has a background color of silver (#C0C0C0), however any other post, like the second or third post, don’t. They have no background color.

This stuff (turning blue on click) is accomplished using JavaScript. What I identified from this is that the JS isn’t working for any other post besides the first post. To resolve this, I tried changing the position of the JS in the code because I thought it had something to do with the scope, but it didn’t. Please help, with the JS and the background color issue.

PHP/HTML/CSS Code:

<style>
.textPost {
  margin-top: 170px;
  width: 650px;
  height: 400px;
  position: fixed;
  background-color: #C0C0C0;
  margin-left: 685px;
  border-radius: 15px;
}

.textpostFormat {
  margin-left: -640px;
  position: fixed;
}
</style>

<div class="textPost">
  <?php

  $sql = "SELECT * FROM posts";
  $result = mysqli_query($connection, $sql);
  if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {

  ?>
  <div class="textpostFormat" id="textpostFormat">
    // all the post content (like, comment buttons, etc.)
  </div>
  <?php

  }
}

  ?>
</div>

AJAX code (to display posts without page refresh):

function makePost() {
  var postContent = $("#postContent").val();
  if (postContent.length > 0) {
    jQuery.ajax({
      url:"yourposts.php",
      data:{
        postContent: postContent
      },
      type:"POST",
      success:function(data){
        if (data == "success") {
          $("#textPostFormat").html(postContent);
        }
      }
    });
  }
}

Javascript code (for turning like button blue and stuff):

<script type="text/javascript">

function changetextUpvote() {
  var textUpvoteImg = document.getElementById('textUpvoteImg');
  if (textUpvoteImg.src.match("orangeupvote")) {
    textUpvoteImg.src = "img/upvote.png";
  } else {
    textUpvoteImg.src = "img/orangeupvote.png";
    textDownvoteImg.src = "img/downvote.png";
  }
}

function changetextDownvote() {
  var textDownvoteImg = document.getElementById('textDownvoteImg');
  if (textDownvoteImg.src.match("orangedownvote")) {
    textDownvoteImg.src = "img/downvote.png";
  } else {
    textDownvoteImg.src = "img/orangedownvote.png";
    textUpvoteImg.src = "img/upvote.png";
  }
}

function textLikeClick() {
  document.getElementById('textLike').style.color = "blue";
}

function textCommentClick() {
  document.getElementById('textComment').focus();
}

</script>

Is there a way to reduce expected conv2d_Conv2D1_input from 4 dimensions to 3?

Problem:

  • a ValueError is saying that conv2d_Conv2D1_input is expecting to have 4 dimension(s), but got array with shape [475,475,3]

However:

  • The inputShape is set to [475,475,3]
  • when logged, tensors have the shape [475,475,3]

Error: ValueError: Error when checking : expected conv2d_Conv2D1_input to have 4 dimension(s), but got array with shape [475,475,3]

Tensor:

Tensor {
  kept: false,
  isDisposedInternal: false,
  shape: [ 475, 475, 3 ],
  dtype: 'int32',
  size: 676875,
  strides: [ 1425, 3 ],
  dataId: {},
  id: 8,
  rankType: '3',
  scopeId: 4
}

Complete Code:

var tf = require('@tensorflow/tfjs');
var tfnode = require('@tensorflow/tfjs-node');
var fs = require(`fs`)

const main = async () => {
  const loadImage = async (file) => {
    const imageBuffer = await fs.readFileSync(file)
    const tensorFeature = await tfnode.node.decodeImage(imageBuffer, 3)
    return tensorFeature;
  }

  const tensorFeature = await loadImage(`./1.png`)
  const tensorFeature2 = await loadImage(`./4.png`)
  const tensorFeature3 = await loadImage(`./7.png`)

  console.log(tensorFeature)
  console.log(tensorFeature2)
  console.log(tensorFeature3)

  tensorFeatures = [tensorFeature, tensorFeature2, tensorFeature3]

  labelArray = [0, 1, 2]
  tensorLabels = tf.oneHot(tf.tensor1d(labelArray, 'int32'), 3);

  const model = tf.sequential();
  model.add(tf.layers.conv2d({
    inputShape: [475, 475, 3],
    filters: 32,
    kernelSize: 3,
    activation: 'relu',
  }));
  model.add(tf.layers.flatten());
  model.add(tf.layers.dense({units: 3, activation: 'softmax'}));

  model.compile({
    optimizer: 'sgd',
    loss: 'categoricalCrossentropy',
    metrics: ['accuracy']
  });

  model.summary()

  model.fit(tf.stack(tensorFeatures), tensorLabels)

  const im = await loadImage(`./2.png`)
  model.predict(im)
}
main()

Why can’t I get text with .text method when text exists?

I’m practicing web scraping using Selenium, and I hope to get the color of this dress. When I inspect the website, I can see the text content under the ‘screen-reader-text’ class but when I try to fetch it, I always get an empty value. What’s going on? Is it because the Zara website blocks me to scrape it? My code is the following,

driver_path = 'D:/Python/Selenium/chromedriver'
option1 =  webdriver.ChromeOptions()
option1.add_experimental_option('detach',True)

driver = webdriver.Chrome(chrome_options=option1,executable_path=driver_path)
driver.get(url)

color = driver.find_element_by_xpath('//*[@id="main"]/article/div[1]/div[2]/div[1]/div[3]/ul/li[1]/button/span/span/span').text

Since I wish to get all the possible colors, I also tried the following code, which doesn’t work as well:(

colors = driver.find_elements_by_xpath('//*[@id="main"]/article/div[1]/div[2]/div[1]/div[3]/ul')
col = []
for i,color in enumerate(colors):
    prefix = '//*[@id="main"]/article/div[1]/div[2]/div[1]/div[3]/ul'
    try: 
        col.append(color.find_elements_by_xpath(prefix+f'/li[{i}]'+'/button/span/span/span').text)
    except:
        pass
col

enter image description here

Why Lazy load doesn’t Perfectly?

Hello there I working on lazy load images and it works perfectly, but I face a problem when I have to add, different attributes in images extension to enhance the quality.

when I scroll down to the bottom at class has been added lazy-img, src attribute src has been implemented into the image tag and lazy load works perfectly.

where is my code which will only at the class lazy-img

this is the older jsFiddle not working
Older jsFiddle code

$(function($) {
  /**
   * @return {?}
   */
  $.fn.lazyimg = function() {
    return this.each(function() {
      /**
       * @return {undefined}
       */
      function o() {
        var threshold = $(window).height();
        if ($(window).scrollTop() + threshold > t.offset().top) {
          /** @type {!Image} */
          var a = new Image;
          /**
           * @return {undefined}
           */
          a.onload = function() {
            t.addClass("lazy-img");
          };
          a.src = s;
        }
      }
      var t = $(this);
      var a = t.attr("src");
      /** @type {number} */
      var i = Math.round(t.height());
      /** @type {string} */
      var s = "";
      s = a.match("s72-c") ? a.replace("/s72-c", i) : a;
      $(window).on("load scroll", o);
      o();
    });
  };
});

on other hand, in same condition my friend also used is jQuery code, which works perfectly without any problem.
he told me just rewrite the code reshuffle and use it for your project, but due to insufficient knowledge about jQuery I am not able to do this anyone can help me to rewrite this code again.

New jsFiddle working file
jsFiddle New

Please check this jsFiddle file it’s perfectly working for lazy load I want to arrange this code and so that I can use in my project.

I know it’s doesn’t sound good but I have to do nothing more good options available to use lazy load.
The permission has been taken from my friend that I can use this code for my project

Any kind of help or advice is highly appreciated

Get hidden input value on form POST after redirect to another page?

I’m using Visual Studio with asp.net, vb.net, and javascript in order to implement an API. I am editing sample code from Authorize.Net.

I need to pass the values of dataValue and dataDescriptor

<input type="hidden" name="dataValue" id="dataValue" />
<input type="hidden" name="dataDescriptor" id="dataDescriptor" />

to the next page after the form POSTS

    'This returns as EMPTY!!! right now
    Dim infoValue = Request.Form("dataValue")
    Dim infoDescriptor = Request.Form("dataDescriptor")

How can I pass these two hidden field values over to the next page?

FULL CODE

PaymentInfo.aspx

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="PaymentInfo.aspx.vb" Inherits="AuthorizeAccept.PaymentInfo" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<!--
    This file is a standalone HTML page demonstrating usage of the Authorize.net
    Accept JavaScript library when integrated with your own payment form.

    For complete documentation for the Accept JavaScript library, see
    https://developer.authorize.net/api/reference/features/acceptjs.html
-->
<head runat="server">
    <title>Sample form</title>
</head>

<body>

<script type="text/javascript"
    src="https://jstest.authorize.net/v1/Accept.js"
    charset="utf-8">
</script>

<form id="paymentForm" runat="server"
    method="POST"
    action="PaymentProcess.aspx" >
    <input type="text" name="cardNumber" id="cardNumber" placeholder="cardNumber" value="4111111111111111"/> <br><br>
    <input type="text" name="expMonth" id="expMonth" placeholder="expMonth" value="12"/> <br><br>
    <input type="text" name="expYear" id="expYear" placeholder="expYear" value="2028"/> <br><br>
    <input type="text" name="cardCode" id="cardCode" placeholder="cardCode" value="123"/> <br><br>
    <input type="text" name="amount" id="amount" placeholder="cardCode" value="6.00"/> <br><br>
    <input type="text" name="accountNumber" id="accountNumber" placeholder="accountNumber"/> <br><br>
    <input type="text" name="routingNumber" id="routingNumber" placeholder="routingNumber"/> <br><br>
    <input type="text" name="nameOnAccount" id="nameOnAccount" placeholder="nameOnAccount"/> <br><br>
    <input type="text" name="accountType" id="accountType" placeholder="accountType"/> <br><br>
    <input type="hidden" name="dataValue" id="dataValue" />
    <input type="hidden" name="dataDescriptor" id="dataDescriptor" />
    <button type="button" onclick="sendPaymentDataToAnet()">Pay</button>
</form>

<script type="text/javascript">

function sendPaymentDataToAnet() {
    var authData = {};
    authData.clientKey = "6bpMZ759ELh6K3dAWx7MVNqyYX88zsN5R3zj7FChrwnYjTQ3bQ93TS7h6YjcE64M";
    authData.apiLoginID = "93cWyMh9Kd6G";

    var cardData = {};
        cardData.cardNumber = document.getElementById("cardNumber").value;
        cardData.month = document.getElementById("expMonth").value;
        cardData.year = document.getElementById("expYear").value;
        cardData.cardCode = document.getElementById("cardCode").value;

    // If using banking information instead of card information,
    // build a bankData object instead of a cardData object.
    //
    // var bankData = {};
    //     bankData.accountNumber = document.getElementById('accountNumber').value;
    //     bankData.routingNumber = document.getElementById('routingNumber').value;
    //     bankData.nameOnAccount = document.getElementById('nameOnAccount').value;
    //     bankData.accountType = document.getElementById('accountType').value;

    var secureData = {};
        secureData.authData = authData;
        secureData.cardData = cardData;
        // If using banking information instead of card information,
        // send the bankData object instead of the cardData object.
        //
        // secureData.bankData = bankData;

    Accept.dispatchData(secureData, responseHandler);

    function responseHandler(response) {
        if (response.messages.resultCode === "Error") {
            var i = 0;
            while (i < response.messages.message.length) {
                console.log(
                    response.messages.message[i].code + ": " +
                    response.messages.message[i].text
                );
                i = i + 1;
            }
        } else {
            paymentFormUpdate(response.opaqueData);
        }
    }
}

function paymentFormUpdate(opaqueData) {
    document.getElementById("dataDescriptor").value = opaqueData.dataDescriptor;
    document.getElementById("dataValue").value = opaqueData.dataValue;

    // If using your own form to collect the sensitive data from the customer,
    // blank out the fields before submitting them to your server.
    document.getElementById("cardNumber").value = "";
    document.getElementById("expMonth").value = "";
    document.getElementById("expYear").value = "";
    document.getElementById("cardCode").value = "";
    document.getElementById("accountNumber").value = "";
    document.getElementById("routingNumber").value = "";
    document.getElementById("nameOnAccount").value = "";
    document.getElementById("accountType").value = "";

    document.getElementById("paymentForm").submit();
}
</script>

</body>
</html>

PaymentProcess.aspx

Imports System
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Collections.Generic
Imports AuthorizeNet.Api.Controllers
Imports AuthorizeNet.Api.Contracts.V1
Imports AuthorizeNet.Api.Controllers.Bases

Public Class PaymentProcess
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'EMPTY!!!
        Dim infoValue = Request.Form("dataValue")
        Dim infoDescriptor = Request.Form("dataDescriptor")

        Run()
    End Sub

    Private Sub Run()
        ' Public Shared Function Run(ByVal ApiLoginID As String, ByVal ApiTransactionKey As String, ByVal amount As Decimal) As ANetApiResponse
        Console.WriteLine("Create an Accept Payment Transaction Sample")
        ApiOperationBase(Of ANetApiRequest, ANetApiResponse).RunEnvironment = AuthorizeNet.Environment.SANDBOX
        ApiOperationBase(Of ANetApiRequest, ANetApiResponse).MerchantAuthentication = New merchantAuthenticationType() With {
                .name = ConfigurationManager.AppSettings("AUTHORIZE_NET_API_LOGIN"),
                .ItemElementName = ItemChoiceType.transactionKey,
                .Item = ConfigurationManager.AppSettings("AUTHORIZE_NET_TRANSACTION_KEY")
            }
        Dim opaqueData = New opaqueDataType With {
                .dataDescriptor = "COMMON.ACCEPT.INAPP.PAYMENT",
                .dataValue = "119eyJjb2RlIjoiNTBfMl8wNjAwMDUyN0JEODE4RjQxOUEyRjhGQkIxMkY0MzdGQjAxQUIwRTY2NjhFNEFCN0VENzE4NTUwMjlGRUU0M0JFMENERUIwQzM2M0ExOUEwMDAzNzlGRDNFMjBCODJEMDFCQjkyNEJDIiwidG9rZW4iOiI5NDkwMjMyMTAyOTQwOTk5NDA0NjAzIiwidiI6IjEuMSJ9"
            }
        Dim billingAddress = New customerAddressType With {
            .firstName = "John",
            .lastName = "Doe",
            .address = "123 My St",
            .city = "OurTown",
            .zip = "98004"
        }
        Dim paymentType = New paymentType With {
            .Item = opaqueData
        }
        Dim lineItems = New lineItemType(1) {}
        lineItems(0) = New lineItemType With {
            .itemId = "1",
            .name = "t-shirt",
            .quantity = 2,
            .unitPrice = New Decimal(15.0)
        }
        lineItems(1) = New lineItemType With {
            .itemId = "2",
            .name = "snowboard",
            .quantity = 1,
            .unitPrice = New Decimal(450.0)
        }
        Dim transactionRequest = New transactionRequestType With {
            .transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),
            .amount = "5.00",
            .payment = paymentType,
            .billTo = billingAddress,
            .lineItems = lineItems
        }
        Dim request = New createTransactionRequest With {
            .transactionRequest = transactionRequest
        }
        Dim controller = New createTransactionController(request)
        controller.Execute()
        Dim response = controller.GetApiResponse()

        If response IsNot Nothing Then

            If response.messages.resultCode = messageTypeEnum.Ok Then

                If response.transactionResponse.messages IsNot Nothing Then
                    Console.WriteLine("Successfully created transaction with Transaction ID: " & response.transactionResponse.transId)
                    Console.WriteLine("Response Code: " & response.transactionResponse.responseCode)
                    Console.WriteLine("Message Code: " & response.transactionResponse.messages(0).code)
                    Console.WriteLine("Description: " & response.transactionResponse.messages(0).description)
                    Console.WriteLine("Success, Auth Code : " & response.transactionResponse.authCode)
                Else
                    Console.WriteLine("Failed Transaction.")

                    If response.transactionResponse.errors IsNot Nothing Then
                        Console.WriteLine("Error Code: " & response.transactionResponse.errors(0).errorCode)
                        Console.WriteLine("Error message: " & response.transactionResponse.errors(0).errorText)
                    End If
                End If
            Else
                Console.WriteLine("Failed Transaction.")

                If response.transactionResponse IsNot Nothing AndAlso response.transactionResponse.errors IsNot Nothing Then
                    Console.WriteLine("Error Code: " & response.transactionResponse.errors(0).errorCode)
                    Console.WriteLine("Error message: " & response.transactionResponse.errors(0).errorText)
                Else
                    Console.WriteLine("Error Code: " & response.messages.message(0).code)
                    Console.WriteLine("Error message: " & response.messages.message(0).text)
                End If
            End If
        Else
            Console.WriteLine("Null Response.")
        End If
    End Sub
    '   Return response
    'End Function
End Class

How do you have document.write result to drawing the same square size but with different calculated metrics?

I am creating a picture matting calculator which you can find the code on JSFiddle here.

The output I am trying to achieve is a large picture frame (a square) that’s always the same size, and that the results of:

Width: document.write((1/2)*(hf-hp+o));
Height: document.write((1/2)*(wf-wp+o));

…are placed in the appropriate location of the width & height of the square.

For example, if I enter the following information into my calculator on JSFiddle:

Example of calculator inputs

The output should be:

Width = 1.625 or 1 5/8
Height = 2.625 or 2 5/8

Therefore, the output should look like this:

Example image of output

Here is another JSFiddle of what I’ve attempted to do. I replaced my document.write((1/2)*(hf-hp+o)); with document.write(6 + 7); in order to show how I want it displayed. I need help with how to incorporate this JSFiddle code with this JSFiddle code. I’m not sure if this is even the correct approach.

Currently, my calculator’s output look like this with the above input example: 1.6252.625. This is correct, but both answers are bunched together: 1.625 and 2.625.

React useState passed as props is not changing in child components

I have this component, it has an array of objects called recogidas, but, i’m putting it within a useState, and, i’m passing it to other components as you can see.

interface ITableProps {
    showDrawer: boolean;
}

const SinAsignarTable: FC<ITableProps> = ({ showDrawer }) => {
    const animationStart = useSelector(getSinAsignarSlide);
    const containerRef = useRef(null);

    const [recogidas, setRecogidas] = useState<any[]>(recogidasSinAsignarArray);

    return (
        <MainContent open={showDrawer} ref={containerRef}>
            {/* Title */}

            <SinAsignarTitle animationStart={animationStart} />

            <TableContainer component={Paper} sx={{ maxHeight: 624, borderRadius: '5px' }}>
                <Table stickyHeader aria-label="customized table" sx={{ minWidth: 800 }}>
                    {/* Header */}
                    <SinAsignarHead recogidas={recogidas} setRecogidas={setRecogidas} />

                    {/* Hero content */}
                    <SinAsignarContent recogidas={recogidas} />
                </Table>
            </TableContainer>
       
        </MainContent>
    );
};

export default SinAsignarTable;

The problem, is that, in SinAsignarHead component, is where i’m updating the useState, but, it only shows the updates after re-rendering the component, let me show you.

SinAsignarHead component

const SinAsignarHead: FC<{ recogidas: any[]; setRecogidas: Dispatch<SetStateAction<any[]>> }> = ({
    recogidas,
    setRecogidas,
}) => {
    const [descendent, setDescendent] = useState<boolean>(true);

    const handleDataOrganization = (): void => {
        setDescendent(!descendent);
        setRecogidas(recogidas.sort((a: any, b: any) => a.recogida - b.recogida));
        // else setRecogidas(recogidas.sort((a: any, b: any) => b.recogida - a.recogida));
    };

    return (
        <>
            {/* Table's header */}
            <TableHead>
                <TableRow>
                    <TableCell padding="checkbox" sx={{ padding: '0px 0px 0px 4px' }}>
                        <Checkbox color="primary" indeterminate={false} checked={false} />
                    </TableCell>

                    <TableCell align="left" sx={{ padding: '7.5px 16px 7.5px 16px' }}>
                        <div
                            style={{
                                width: '100%',
                                display: 'flex',
                                alignItems: 'center',
                                justifyContent: 'space-between',
                            }}
                        >
                            Recogida
                            <IconButton onClick={handleDataOrganization} sx={{ marginLeft: '5px', padding: '6px' }}>
                                {descendent ? (
                                    <ArrowDownward sx={{ width: 22, height: 22 }} />
                                ) : (
                                    <ArrowUpward sx={{ width: 22, height: 22 }} />
                                )}
                            </IconButton>
                        </div>
                    </TableCell>

                    <TableCell sx={{ minWidth: '255px', padding: '7.5px 16px 7.5px 6.5px' }} align="left">
                        Dirección
                    </TableCell>

                    <TableCell sx={{ minWidth: '115px', padding: '7.5px 16px 7.5px 16px' }} align="left">
                        Ciudad
                    </TableCell>

                    <TableCell sx={{ minWidth: '150px', padding: '7.5px 16px 7.5px 16px' }} align="left">
                        Tipo cuenta
                    </TableCell>

                    <TableCell sx={{ minWidth: '105px', padding: '7.5px 16px 7.5px 16px' }} align="left">
                        Producto
                    </TableCell>

                    <TableCell sx={{ minWidth: '165px', padding: '7.5px 16px 7.5px 16px' }} align="left">
                        Contacto
                    </TableCell>
                </TableRow>
            </TableHead>
        </>
    );
};

export default SinAsignarHead;

When handleDataOrganization function executes, it should update recogidas’s state, but it doesn’t.

This is SinAsignarContent

const SinAsignarContent: FC<{ recogidas: any[] }> = ({ recogidas }) => {
    return (
        <TableBody>
            {recogidas.map(({ recogida, direccion, ciudad, tipoDeCuenta, producto, contacto }, index) => {
                // const sinAsignarData = {
                //     recogida,
                //     direccion,
                //     ciudad,
                //     tipoDeCuenta,
                //     producto,
                //     contacto,
                // };
                return (
                    <TableRow key={index}>
                        <TableCell padding="checkbox" sx={{ padding: '0px 0px 0px 4px' }}>
                            <Checkbox color="primary" checked={true} />
                        </TableCell>

                        <TableCell
                            sx={{
                                color: '#086BB5',
                                fontWeight: 500,
                                cursor: 'pointer',
                                padding: '5px 20px 5px 0px',
                            }}
                            align="center"
                        >
                            {recogida}
                        </TableCell>

                        <TableCell
                            sx={{
                                color: '#00000099',
                                cursor: 'pointer',
                                padding: '5px 16px 5px 6.5px',
                            }}
                            align="left"
                        >
                            {direccion}
                        </TableCell>

                        <TableCell
                            sx={{ color: '#00000099', cursor: 'pointer', padding: '5px 16px 5px 16px' }}
                            align="left"
                        >
                            {ciudad}
                        </TableCell>

                        <TableCell
                            sx={{ color: '#00000099', cursor: 'pointer', padding: '5px 16px 5px 16px' }}
                            align="left"
                        >
                            {tipoDeCuenta}
                        </TableCell>

                        <TableCell
                            sx={{ color: '#00000099', cursor: 'pointer', padding: '5px 16px 5px 16px' }}
                            align="left"
                        >
                            {producto}
                        </TableCell>

                        <TableCell
                            sx={{ color: '#00000099', cursor: 'pointer', padding: '5px 16px 5px 16px' }}
                            align="left"
                        >
                            {contacto}
                        </TableCell>
                    </TableRow>
                );
            })}
        </TableBody>
    );
};

export default SinAsignarContent;

I’ve used useState in other ocations, where, i pass data as props, and update it whit no problem, why is not working this time ? why am i being forced to re-render component ?

JSON data is not visible on Network while opening React App in mobile [duplicate]

I’m running my react app in PC using npm start

You can now view musical-world in the browser.   

  Local:            http://localhost:3000        
  On Your Network:  http://xxx.xxx.xx.xxx:3000 

I want to see this app on my mobile so, I follow this link http://xxx.xxx.xx.xxx:3000 in mobile and App is visible but my JSON server data is not visible means everything is showing or working fine except JSON data.

My JSON server data is available here http://localhost:3001/songs

So what I need to do here?

Like when i worked on php i used xampp in that case i was able to see my data in mobile even it was on mysql server.

api search bar doesn’t refresh after first search

I created a search bar with vanilla js that loads items from an API array. When I search for the first time, it loads an image, title, and price. but when you type in a second search, the list does not refresh. You also can’t click out of it.

<body>
<input type="text" id="searchBar" onkeyup="getItemList()"   class="blgSearch" name="search bar" placeholder="Type In Item"><button id="searchBtn" onclick="btnFunction" type="submit">search</button> 
<div id="itemsFilter">
   <!-- <div class="item">
       <img src="" alt="image"/> 
       <h2>Item Title</h2>
       <div>cost</div></div> -->

</div>

  <script src="/search.js"></script>

and script

  //connect to API
let path = "<path>"; 
let devKey = "<key>";
let token =  "<token>";

const api = path+ devKey + token;
const url = encodeURI(api) 
let itemsList= [];

window.addEventListener('DOMcontentLoaded', loadContent)

//displays loaded content
function loadContent(){
    getItemList();
    btnfunction();   
}

fetch(url)
    .then (res => res.json()) 
    .then(data => {console.log(data); itemsList= data})

//activate on keyup
const searchBar = document.getElementById('searchBar');
//activate onclick
// const searchBtn = document.getElementById('searchBtn');

//searchBar.addEventListener("keyup", getItemList); 
const itemsFilter = document.getElementById('itemsFilter');


//filter out items by name 
function getItemList(){
    console.log(itemsList);
    let filteredItems= itemsList.rows.filter(item=> item.name.includes(searchBar.value));

    //create the filtered items element
    filteredItems.forEach(filteredItem => {
        let itemDiv = `
        <div class="item">
        <img src="${filteredItem.picture}" class="filteredImg" alt=""/> 
        <h2 class="itemName" >${filteredItem.name}</h2>
        <div class="itemPrice" >$${filteredItem.base_cost}</div>
        </div>
        `
        itemsFilter.insertAdjacentHTML("beforeend", itemDiv);
    });
}

function searchBnt() { 

}
 

any tips?