Change from ScrollView to FlatList in react native

I’m going to make a todolist app.
On the main page, to show the task of todolist,
I used scrollview, but I want to change it to FlatList.

<ScrollView width = {width-20}>
            {Object.values(tasks).map(item => (
               <Task key = {item.id} item={item} deleteTask={_deleteTask} 
               toggleTask={_toggleTask} updateTask={_updateTask}/>
           ))} 
         </ScrollView>

“too much recursion” while updating params(setData) into Firebase RTDB through setInterval and getData

I’m new to react native. I have a problem while updating data(latitude, longitude, timestamp) for each user(member) to Firebase database realtime, I get endless loops

The error I have “too much recursion”

firebase.config.ts

const firebaseConfig = {
    ...
};

export const getCurrentLocation = (phoneNumber: number, setData: (locationParams: any) => void) => {
    const db = getDatabase();
    const reference = ref(db, 'members/' + phoneNumber);
    onValue(reference, (snapshot) => {
        const data = snapshot.val();
        setData(data);
    })
};


export const setCurrentLocation = (phoneNumber: number, latitude: number, longitude: number, timestamp: number) => {
    const db = getDatabase();
    const reference = ref(db, 'members/' + phoneNumber);
    set(reference, {
        latitude: latitude,
        longitude: longitude,
        timestamp: timestamp,
    }).then(() => console.log('setCurrentLocation to mainUser/firebase.config'));
};
const app = initializeApp(firebaseConfig);



memberList.tsx

const [userPhoneNumber, setUserPhoneNumber] = useState('0');
const members = useSelector((state: any) => state.members);

//get user's phoneNumber
const auth = getAuth();
    useEffect( ()=> {
        onAuthStateChanged(auth, (user) => {
            if (user) {
                setUserPhoneNumber(user.email.replace(/D/gi, '') || '');
            } else {
                console.log('logged out')
            }
        });
    }, [])


useEffect(() => {
        const timer = setInterval( () => {
            
            members.map(function (el) {
                getCurrentLocation(el.phoneNumber, (locationParams: any) => {
                    let timestamp = new Date().getTime()/1000;
              
                    setCurrentLocation(el.phoneNumber, locationParams.latitude, locationParams.longitude, timestamp)
                })
            })
        }, 10000);

        return () => clearInterval(timer);
    }, []);

Misunderstanding csInterface for Adobe CEP extensions

I’m trying to write a basic After Effects extension and, while the extension is recognized and the html displays, I can’t seem to use csInterface to access anything in ae. I’m just trying to get an alert message to display for right now. I’m sure I’m missing something obvious, please help.

index.html:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Help Video Helper</title>
        <meta name="description" content="AE extension adding various functions for creating help videos">
        <link rel="stylesheet" href="./css/styles.css">
        <script type="text/javascript" src="./js/main.js"></script>
        <script type="text/javascript" src="./lib/CSInterface.js"></script>
    </head>
    <body>     
        <div class="container">
            <div class="control-div">
                <p class="control-label">Keyframe Hotkey</p>
                <input class="control-input" id="hotkey-keyframe-input" value="2" /></div>
            </div>
            <div class="control-div">
                <p class="control-label">Skip Forward Hotkey</p>
                <input class="control-input" id="hotkey-skip-input" value="2" /></div>
            </div>
            <button class="control-button" id="testButton">Test</button>
        </div>  
    </body>
</html>

main.js:

var csInterface = new CSInterface();

var testButton = document.getElementById('testButton');
testButton.addEventListener('click', test);

function test() {
    csInterface.evalScript("alert('hello world')");
};

Here’s the whole repo if anyone is interested: https://github.com/Wi-ll-iam/hvhelper/tree/master

Returning response instead of undefined [duplicate]

I know this has been answered 38 million times elsewhere but I’m dumb. Please hammer it into my brain.

faxResponse is returning undefined. I’m trying to do something like the below:

const Base64String = async (req, res) => {
  let faxResponse = await postFax(req.body);
  console.log(faxResponse); // undefined

  if (faxResponse.status == "fail") {
    return res.status(200).send({
      statusCode: 400,
      message: faxResponse.error,
    });
  } else {
    return res.status(200).send({
      statusCode: 200,
      data: {
        ...req.body,
      },
      faxResponse,
    });
  }
};

const postFax = async ({
  login,
  pass,
  faxnum,
  faxsrc,
  recname,
  file1,
  data1,
}) => {
  const VITELITY_URL = `https://api.vitelity.net/fax.php?login=${login}&pass=${pass}&cmd=sendfax`;

  let formdata = new FormData();
  formdata.append("faxnum", faxnum);
  formdata.append("faxsrc", faxsrc);
  formdata.append("recname", recname);
  formdata.append("file1", file1);
  formdata.append("data1", data1);

  await fetch(VITELITY_URL, {
    method: "POST",
    body: formdata,
    redirect: "follow",
  })
    .then((res) => res.text())
    .then((result) => {
      console.log(result);
    })
    .catch((err) => console.log(err));
};

Webpack issue with MUI and Next.JS

I’m copying the instructions from this file here:

https://github.com/mui-org/material-ui/blob/master/examples/nextjs-with-styled-components-typescript/next.config.js

I get this error when I add the next.config.js code below.

WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration[0].module.rules[1].oneOf[5].include should be one of these:
   RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? } | [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
   -> One or multiple rule conditions
   Details:
    * configuration[0].module.rules[1].oneOf[5].include.or[2] should be an instance of RegExp
    * configuration[0].module.rules[1].oneOf[5].include.or[2] should be a string.
    * configuration[0].module.rules[1].oneOf[5].include.or[2] should be an instance of function
    * configuration[0].module.rules[1].oneOf[5].include.or[2] should be an array:
      [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
    * configuration[0].module.rules[1].oneOf[5].include.or[2] should be an object.
    * configuration[0].module.rules[1].oneOf[5].include.or[2] should be one of these:
      RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }
    * configuration[0].module.rules[1].oneOf[5].include.or[2] should be one of these:
      RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }
      -> A rule condition
 - configuration[1].module.rules[1].oneOf[3].issuer should be one of these:
   RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? } | [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
   -> One or multiple rule conditions
   Details:
    * configuration[1].module.rules[1].oneOf[2].issuer.or should be an array:
      [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
    * configuration[1].module.rules[1].oneOf[2].issuer.or should be one of these:
      [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
      -> Logical OR
    * configuration[1].module.rules[1].oneOf[3].issuer.or should be an array:
      [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
    * configuration[1].module.rules[1].oneOf[3].issuer.or should be one of these:
      [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
      -> Logical OR
    at webpack (/Users/thomasreggi/Desktop/project-template/node_modules/next/node_modules/webpack/lib/webpack.js:31:9)
    at HotReloader.start (/Users/thomasreggi/Desktop/project-template/node_modules/next/dist/server/hot-reloader.js:14:1858)
    at async DevServer.prepare (/Users/thomasreggi/Desktop/project-template/node_modules/next/dist/server/next-dev-server.js:10:1565)
    at async /Users/thomasreggi/Desktop/project-template/node_modules/next/dist/cli/next-dev.js:21:359
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
const withTM = require('next-transpile-modules')(['@mui/material', '@mui/system']); // pass the modules you would like to see transpiled

module.exports = withTM({
  reactStrictMode: true,
  webpack: (config) => {
    config.resolve.alias = {
      ...config.resolve.alias,
      '@mui/styled-engine': '@mui/styled-engine-sc',
    };
    return config;
  },
});

Onmouseover change image transition

I have the following code snippet to change the src of an img tag when I hover over it.

<img src="./Path/to/image.png" alt="" class="exhibit-banner-img" onmouseover="this.src='./Path/to/newimage.png'" onmouseout="this.src='./Path/to/image.png'">

It runs as expected, but how do I add a transition time to the image when the event is fired?
Right now, it changes instantly.

Showing a forEach in HTML Element

Im fetching a group of documents in a forEach from Firestore, I know im fetching this all as I can see documents and is fields in the console.

But when I add the id to the field fetched it only shows one document. (it should be 5 tiles and images but I can only see one)

From reading I know I only need to some how duplicate the HTML code based on the documents fetch in the collection but am struggling to do so.

Javascript code

const i = query(collection(db, "teams"));
const unsubscribe = onSnapshot(i, (querySnapshot) => {
            
     querySnapshot.forEach((doc) => {
          const docData = doc.data();

  document.getElementById("ageGroup").innerText = docData.ageGroup,
                document.getElementById("teamImage").src = docData.teamImage,
           
                
                console.log("Current data: ", docData);
                
            });

        });

HTML Code

<section class="teams">
            <article>
                <h1 class="team-names" id="ageGroup"></h1>
                <div class="team-line"></div>
                <img class="team-image" id="teamImage">

            </article>
</section>

Electron app crashes on Windows 8 and Windows 7

I’m building an app using Electron with the purpose to notify a user by new orders from an E-commerce.

Basically, when some customer buy on the E-commerce, than it emits a notification to the store.

I am doing this with Websocket connection. The store log-in the API and then the API sends a socket event when a new order arrived.

On Windows 10, MacOS X and Linux it works as expected.

But when I test on Windows 8 and Windows 7, the app crashes in the first received notification.

I tried to run the project on Windows 8 with VSCode but it didn’t show any error. When I tried to debbug the crash with Visual Studio it drop an error

“Unhandled win32 exception”
and
“Access Violation reading location…”

I am not using the “Notification” class from Electron.

I created a Screen with the message and all the styling things which is hidden in the Tray. And when I receive a event from socket, I call

mainWindow.restore();
playSound();

The window isn’t restore and app crashes.

On Windows 8 I can see a message “The process stopped and a button ‘Exit program’ ” which terminates the process.

On Windows 7 it just crashes without any error.

Sorry about the missing details but everything is working unless this part of the program which fails maybe on restoring the window or maybe on receiving a event from socket, or maybe playing the sound.

Download blob in frontend got it from database

Thanks in advance, I am new on javacript, but i am building an app for the company I work at to manage some documents.

I have a database when I have to store some docuemnst (I am using blob), I already was able to store the documents in MYSQL but now I need to donwload it.

I fetched the database I already have the Blob data in the frontend. There is any way to download that data to the client computer?

NB: The document type is not limited, so it can be any document.

I can not add registration to my database [duplicate]

I can not add registration to my database , I do not know why but I changed it to a free domain

Since I changed it to a live server and not a xamp server it doesn’t register but when it’s on a localhost server it works but cloud severs it doesn’t register but everything else works

<?php

include('config.php');

if(isset($_POST['submit'])){
    $u_card = $_POST['card_no'];
    $u_f_name = $_POST['user_first_name'];
    $u_l_name = $_POST['user_last_name'];
    $u_father = $_POST['user_father'];
    $u_aadhar = $_POST['user_aadhar'];
    $u_birthday = $_POST['user_dob'];
    $u_gender = $_POST['user_gender'];
    $u_email = $_POST['user_email'];
    $u_phone = $_POST['user_phone'];
    $u_state = $_POST['state'];
    $u_dist = $_POST['dist'];
    $u_village = $_POST['village'];
    $u_police = $_POST['police_station'];
    $u_pincode = $_POST['pincode'];
    $u_mother = $_POST['user_mother'];
    $u_family = $_POST['family'];
    $u_staff_id = $_POST['staff_id'];
    


    //image upload

    $msg = "";
    $image = $_FILES['image']['name'];
    $target = "upload_images/".basename($image);

    if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
        $msg = "Image uploaded successfully";
    }else{
        $msg = "Failed to upload image";
    }

    $insert_data = "INSERT INTO student_data(u_card, u_f_name, u_l_name, u_father, u_aadhar, u_birthday, u_gender, u_email, u_phone, u_state, u_dist, u_village, u_police, u_pincode, u_mother, u_family, staff_id,image,uploaded) VALUES ('$u_card','$u_f_name','$u_l_name','$u_father','$u_aadhar','$u_birthday','$u_gender','$u_email','$u_phone','$u_state','$u_dist','$u_village','$u_police','$u_pincode','$u_mother','$u_family','$u_staff_id','$image')";
    $run_data = mysqli_query($con,$insert_data);

    if($run_data){
          $added = true;
    }else{
        echo "Data not insert";
        
    }

}

?>