Cannot call `setState` with function bound to `state` because function [1] is incompatible with array type [2]

In my react app (using Flow for type checking), I have the following setup:

type Filter = {
    title: string,
    value: string
};

export type State ={
    filter: Array<Filter>
}

export type Actions<T> = {
    setFilters: (filter: Array<Filter>) => T
}

In my component, I need to merge the newly created/modified data with the previous array object in the state.

I am initializing the state in useEffect based upon some conditions. The first setState() (inside first if() check) works fine.

But during the second setState(), I get the following error:

Cannot call `setFilters` with function bound to `filter` because  function [1] is incompatible with  array type [2]

Where,

1 denotes

setFilters((prevState) => {
   return [...prevState, ...newData];
});

and [2] denotes setFilters: (filter: Array<Filter>) => T

//
.....

useEffect(() => {
    if (current) {
      setFilters([
        {
          title: 'abc',
          value: '1'
        },
      ]);
    }

    if (current && old) {
      const newData = old.map((datum) => ({
        title: datum.title,
        value: datum.value,
      }));

      setFilters((prevState) => {
        return [...prevState, ...newData];
      });
    }
  }, [current, old]);

.....
//

Sample data:

const old = [
    {
        title: 'oldabc',
        value: '1',
        status: 'expired',
        count: 2
    },
    {
        title: 'oldxyz',
        value: '2',
        status: 'pending',
        count: 4
    },
    ....
];

the final result required:

[
    {
        title: 'abc',
        value: '1'
    },
    {
        title: 'oldabc',
        value: '2',
    },
    {
        title: 'oldxyz',
        value: '3'
    },
    ....
]

I am pretty sure there is some silly fix that I am missing, but still unable to figure out how to resolve it. Any help to resolve the same will be appreciated!

Can’t edit the color of them map using arcgis-core react

How can i change the color of the map? I used the @arcGIS/core for importing the map this is my code

this is my style.css

html,
body {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  font-feature-settings: "liga" 1, "calt" 0;
}

#root, .mapDiv {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 500px;
  display: flex;
  letter-spacing: 0em;
  line-height: 1.55rem;
  background-color: gray;
}

this is my map code

....
import style from "../../component/css/style.css";


function MyMap(){
    const mapDiv = useRef(style);
    let cleanup;
    useEffect(()=> {
        if (mapDiv.current) {
            esriConfig.apiKey = ">>>>>>>><<<<<<<<";  
            const map = new Map({
                basemap: "arcgis-topographic" // Basemap layer service
                });
            const view = new MapView({
                map: map,
                container: mapDiv.current,
                center: [-118.805, 34.027], // Longitude, latitude
                zoom: 13, // Zoom level
                style: {
                    background: {
                      type: "color",
                      color: [192, 192, 192, 0.4]
                    },
                }
            })
            view.when((r)=> {
            }).then(()=> {
                mapDiv.current = view;
            });
        }
    },[])
    return (
        <div className="mapDiv" ref={mapDiv}>

        </div>
    )
}
export default MyMap

result

enter image description here

from this line please dont read it from this line please dont read it
from this line please dont read it from this line please dont read it
from this line please dont read it from this line please dont read it
from this line please dont read it

Navigate to another page with data in a React Component after fetch

I am new to React + typescript and is trying to use “react-router-dom” to make a login component to communicate with my backend server.

Basically I am trying to make a class “Login” that, upon submitting a form, will trigger a fetch request to my server. If the response from my server is OK, I will then navigate to another page with the input data.

Everything works fine until I try to navigate to my second page. The thing is, I don’t want the login credentials to appear in the url, and the rule of hooks is preventing me from using the navigate hook after checking the status code of my fetch response.

Does anyone have an idea about how I can achieve this? Any help would be appreciated.

Adding custom class on slick slider when slide count exceed more then 3 on mobile devices

I need to add custom class on slick slider when it exceed the slide count (3) on mobile device so i can change padding of slide nav when displayed on mobile device with more then 3 slides.
here is my slick code.

$('.bundleTitleCarousel').slick({
        slidesToShow: maxItems,
        slidesToScroll: 1,
        accessibility:false,
        draggable: false,
        asNavFor: '#bundle-lp-product-slider',
        dots: false,
        arrows: false,
        infinite: false,
        waitForAnimate: false,
        focusOnSelect: true,
        centerPadding:'0px',
        mobileFirst:true,
        responsive: [
            {
                breakpoint: 767,
                settings: {
                    slidesToShow: maxItems,
                    slidesToScroll: 1
                }
            },
            {
                breakpoint: 320,
                settings: {
                    slidesToShow: 3,
                    slidesToScroll: 1
                }
            }
            // You can unslick at a given breakpoint now by adding:
            // settings: "unslick"
            // instead of a settings object
        ]
    });

Issue when trying to render list inside of vue-virtual-scroll-list in Vuejs?

< script >
  export default {
    name: 'App',
    data() {
      return {
        items: [{
            price: '1',
            name: 'mm'
          },
          {
            price: '22',
            name: 'aa'
          },
          {
            price: '55',
            name: 'dd'
          },
          {
            price: '77',
            name: 'gg'
          },
          {
            price: '123',
            name: 'kk'
          },
          {
            price: '53',
            name: 'mn'
          },
          {
            price: '11',
            name: 'mm'
          },
          {
            price: '22',
            name: 'a'
          },
          {
            price: '33',
            name: 'd'
          },
          {
            price: '77',
            name: 'g'
          },
          {
            price: '1283',
            name: 'k'
          },
          {
            price: '589',
            name: 'n'
          }
        ]
      }
    }
  } <
  /script>
<template>
  <div id="app">
    <div class="wrapper">
      <virtual-list
        class="list"
        style="height: 360px; overflow-y: auto"
        :data-key="'item'"
        :data-sources="item"
        :data-component="item"
        :estimate-size="3"
      />
      <div class="item" v-for="item in items" :key="item">
        <div class="id">{{ item.price }} {{ item.name }}</div>
      </div>
    </div>
  </div>
</template>

virtual scroll component output

I am trying to achieve virtual scroll in vuejs, I am able to render list in ui also, But unable to render them in virtual scroll. as shown in the image.

codesandbox link :- https://codesandbox.io/s/live-demo-virtual-list-forked-bkckf?file=/src/App.vue

reference link:- https://www.npmjs.com/package/vue-virtual-scroll-list

tried installing :- npm install vue-virtual-scroll-list –save

threejs how to load gltf model textures

hey guys i am new to threejs and i am trying to load my gltf models and their respectives textures using gltf models. i heard that gltf loaders automatically load the textures along with the models respectively, but that seems to be not the case here as it missed out the textures hence the errors any ideas how to solve this? thanks in advance

canglong_normal.png:1 GET http://127.0.0.1:5500/textures/canglong_normal.png 404 (Not Found)

canglong_metallicRoughness.png:1 GET http://127.0.0.1:5500/textures/canglong_metallicRoughness.png 404 (Not Found)

canglong_baseColor.png:1 GET http://127.0.0.1:5500/textures/canglong_baseColor.png 404 (Not Found)

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>3d model</title>
    <style>
      body {
        margin: 0;
      }
      canvas {
        position: fixed; top: 0; left: 0;

      }
      div#test2 {
  height: 5000px;
}
    </style>
  </head>
  

  <body>
    <script type="module">
        import * as THREE from 'https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js';
        
        import { OrbitControls } from 'https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/controls/OrbitControls.js';
        import { GLTFLoader } from 'https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/loaders/GLTFLoader.js';
        import { RGBELoader } from 'https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/loaders/RGBELoader.js';
        
        var container, controls;
        var camera, scene, renderer, mixer, clock;
        var obj , material , texture
        
        init();
        animate();
        
        function init() {
        
          container = document.getElementById( 'test' );
          document.body.appendChild( container );
          
          

          camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.01, 1000 );
        //   camera.position.set(0, 5, 30);
          camera.position.x = 0
          camera.position.y = 5
          camera.position.z = 10 


        
          scene = new THREE.Scene();
          scene.background = new THREE.Color(0xffffff);
          var light = new THREE.HemisphereLight(0xffffff,0x000000,10);
          scene.add(light);
    
         var texture = new THREE.MeshMatcapMaterial()

        //  var matcapTexture = new THREE.TextureLoader().load('purple.jpg')

        //  var texture = new THREE.MeshMatcapMaterial( {map: matcapTexture})

        //  console.log(texture)

        

          clock = new THREE.Clock();
        
              // model
          
              var loader = new GLTFLoader();
              loader.load( 'scene.gltf', function ( gltf ) {
                


                obj = scene.add( gltf.scene );
        
                mixer = new THREE.AnimationMixer( gltf.scene );
                
                gltf.animations.forEach( ( clip ) => {
                  
                    mixer.clipAction( clip ).play();
                  
                } );
        
              } );


        
        
          renderer = new THREE.WebGLRenderer( { antialias: true } );
          renderer.setPixelRatio( window.devicePixelRatio );
          renderer.setSize( window.innerWidth, window.innerHeight );
          renderer.toneMapping = THREE.ACESFilmicToneMapping;
          renderer.toneMappingExposure = 0.8;
          renderer.outputEncoding = THREE.sRGBEncoding;
          container.appendChild( renderer.domElement );
        

          function rotateFunction() {
        obj.rotation.y += 0.02;        
        console.log(obj.rotation.y)
        
      }

      document.addEventListener('scroll', function(e) { rotateFunction() });


        
        }
        function onWindowResize() {
          camera.aspect = window.innerWidth / window.innerHeight;
          camera.updateProjectionMatrix();
        
          renderer.setSize( window.innerWidth, window.innerHeight );
        }
        
        //
        
        function animate() {
          requestAnimationFrame( animate );
          var delta = clock.getDelta();
          if ( mixer ) mixer.update( delta );
          renderer.render( scene, camera );
        
        }

        function adjustCamera() {              
    var t = scrollY / (5000 - innerHeight);
    console.log(t)
    // t is 0 to 1

        camera.position.z = 10 + 5 * t;


        }

        document.addEventListener('scroll', function(e) { adjustCamera() });



        </script>
  </body>
  <div id="test">

  </div>

  <div id="test2">

    testing121

  </div>

</html>

How to edit and update Laravel dynamic input fields?

I am a beginner for Laravel and I need to edit and update dynamic input fields. I can able to insert dynamics input values, but I don’t know how to edit and update them. Please, anyone, give me the solution for this. I have given below my code.
My Insert Blade File

<div class="form-group row">
                        <label for="address" class="col-md-4 col-form-label text-md-left">Address</label>
                       
                        <div>
                            <table id="dynamicAddRemove">
                                <tr>
                                    <td><button type="button" name="add" id="add-btn" class="btn btn-success">Add More Details</button></td> 
                                </tr>
                           
                        </table>
                        </div>
                    </div>    
      <script type="text/javascript">
      var i = 0;
      $("#add-btn").click(function(){
    //alert("I am an alert box!");
    ++i;
    $("#dynamicAddRemove").append('<tr><td><input type="text" name="moreFields['+i+'][house_no]" placeholder="House No" class="form-control" /></td><td><input type="text" name="moreFields['+i+'][street_name]" placeholder="Street Name" class="form-control" /></td><td><input type="text" name="moreFields['+i+'][area]" placeholder="Area" class="form-control" /></td><td><input type="text" name="moreFields['+i+'][pincode]" placeholder="Pincode" class="form-control" /></td><td>Primary Address</td><td><input type="radio" class="form-check-input" name="primary_address" value="id"></td><td><button type="button" class="btn btn-danger remove-tr">Remove</button></td></tr>');
     });
     $(document).on('click', '.remove-tr', function(){  
     $(this).parents('tr').remove();
    });  
    </script>

Get line of file content that contain a string

I wanted to get line content in a file that contains a string in discord js node.

Something like this:

If (file contains("string")){
console.log(line content)
}

like, if one of the lines in the file contains the string. It’s gonna send the line that contains the string to the console.

Javascript hexadecimal to ASCII with latin extended symbols

I am getting a hexadecimal value of my string that looks like this:

String has letters with diacritics: č,š,ř, ...

Hexadecimal value of this string is:

0053007400720069006E006700200068006100730020006C0065007400740065007200730020007700690074006800200064006900610063007200690074006900630073003A0020010D002C00200161002C00200159002C0020002E002E002E

The problem is that when i try to convert this value back to ascii it poorly converts the č,š,ř,.. and returns symbol of little box with question mark in it instead of these symbols.

My code for converting hex to ascii:

function convertHexadecimal(hexx){

  let index = hexx.indexOf("~");
  let strInfo = hexx.substring(0, index+1);
  let strMessage = hexx.substring(index+1); 
  var hex  = strMessage.toString();
  var str = '';     
  for (var i = 0; i < hex.length; i += 2){     
      str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));     
  }
  console.log("Zpráva: " + str);
  var strFinal = strInfo + str;
  return strFinal; 
}

Can somebody help me with this?

How to check one of my object value is empty or not

I need to check my java object value is empty or not. And I need to check this one by one.
I crate my code to do this task…But I can’t check values one by one. If all of my object value is empty, my code is working…But it can’t check values one by one.

const coverDesc = action.data.coverDescriptionLocalization;

enter image description here

Methord 01- :-

 if (Object.values(coverDesc ).every((x) => x === null || x === '')) {
        console.log('Empty');
    } else {
        console.log('Not empty');
    }

Methord 02- :-

for (const key in coverDesc) {
    if (coverDesc.hasOwnProperty(key)) {
        if (Object.values(coverDesc[key]).every((x) => x === null || x === '')) {
           console.log('Empty');
        } else {
            console.log('Not empty');
        }
    }
}

Stripe Elements won’t load my custom font

I’m using this code to load a custom font for my Stripe card number element:

const elements = stripe.elements({
                    fonts: [
                        {
                            family: 'Avenir-Regular-Bold',
                
                            src: 'url('styles/AvenirNextLTPro-Bold.otf')'
                        }
                    ]
                });

And I’m getting this error about loading said font:

Access to font at ‘https://example.com/app/styles/AvenirNextLTPro-Bold.otf’ from origin ‘https://js.stripe.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

I have no idea what this means or why Stripe is saying this. Any way I can get my custom font to load?

HERE Maps JavaScript API: how to get info from click on cluster marker

Following these 2 docs:

https://developer.here.com/documentation/examples/maps-js/clustering/custom-cluster-theme

https://developer.here.com/documentation/maps/3.1.30.3/dev_guide/topics/clustering.html

I have a cluster of markers. But the target data from clicking on the cluster marker is different from that from clicking on the noise marker.

  1. How do I distinguish when I click on the cluster and when on the individual marker so that I can display correct info in a bubble?
  2. How do I stop the ridiculous zoom-in and zoom-out effect when clicking on a cluster marker? Because if the map is set to zoom 2 and the noise markers are on zoom 16, when you click on the cluster marker it starts zooming all the way from 2 to 16 and then straight back to 2 without even a chance of loading the maps. This is awful. How can I stop it?

Thank you.