React Native – onPress on child larger than parent component not working on Android

I have the following component in React Native:

<View style={{ flex: 1, width: "100%", backgroundColor: "white" }} >
    <View style={{ position: "absolute", top: 20, left: 20, height: 100, width: 100, backgroundColor: 'red' }}>
        <TouchableWithoutFeedback onPress={() => console.log("clicked")}>
            <View style={{ position: "absolute", top: 20, left: 20, height: 200, width: 200, backgroundColor: 'blue'}}>
            </View>
        </TouchableWithoutFeedback>
    </View>
</View>

This renders the following screen:

Render of component

Now when I click on the part of the child (blue) component that is outside of the parent (red) component it doesn’t log “click” on Android. But when I run this app on iOS, it does log “click” when clicked outside of the parent on the child component.

What is the reason that it does work on iOS but not on Android? Should I use a different component specifically for Android?

Thanks in advance.

Version information:

Output of react-native info:

System:
    OS: macOS 12.0.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 157.67 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.10.0 - /var/folders/0k/l1gbyzj91lzg98pqcyp95xl40000gn/T/yarn--1653119182599-0.2342745454309867/node
    Yarn: 1.22.18 - /var/folders/0k/l1gbyzj91lzg98pqcyp95xl40000gn/T/yarn--1653119182599-0.2342745454309867/yarn
    npm: 7.24.0 - ~/.nvm/versions/node/v16.10.0/bin/npm
    Watchman: 2022.03.21.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
    Android SDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7784292
    Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
  Languages:
    Java: 15.0.2 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.3 => 0.64.3 
    react-native-macos: Not Found

Error: ENOENT: no such file or directory, mkdir ‘/temp’ when I am trying to upload photo

After deployment on Heroku when I am trying to POST a request on URL it gives me this error. I provide an image but it shows me the same error

2022-05-21T06:30:22.053332+00:00 heroku[router]: at=error code=H13 desc=”Connection closed without response” method=POST path=”/api/v1/admin/product/add” host=sharmastoreapi.herokuapp.com request_id=0fd76d2b-f66f-4197-a9a2-5eb9ad4bfbbd fwd=”49.36.235.255″ dyno=web.1 connect=0ms service=224ms status=503 bytes=0 protocol=https

  1. 2022-05-21T06:30:22.055360+00:00 heroku[web.1]: State changed from
    crashed to starting 2022-05-21T06:30:24.972637+00:00 heroku[web.1]:
    Starting process with command npm start
    2022-05-21T06:30:26.591854+00:00 app[web.1]:
    2022-05-21T06:30:26.591887+00:00 app[web.1]: > [email protected]
    start 2022-05-21T06:30:26.591888+00:00 app[web.1]: > node index.js
    2022-05-21T06:30:26.591889+00:00 app[web.1]:
    2022-05-21T06:30:27.994606+00:00 app[web.1]: DB Conneted
    Successfully 2022-05-21T06:30:27.997012+00:00 app[web.1]: Server is
    Running at port:5322 2022-05-21T06:30:28.177589+00:00 heroku[web.1]:
    State changed from starting to up 2022-05-21T06:32:20.187826+00:00
    app[web.1]: node:internal/fs/utils:345
    2022-05-21T06:32:20.187838+00:00 app[web.1]: throw err;
    2022-05-21T06:32:20.187839+00:00 app[web.1]: ^
    2022-05-21T06:32:20.187839+00:00 app[web.1]:
    2022-05-21T06:32:20.187840+00:00 app[web.1]: Error: ENOENT: no such
    file or directory, mkdir ‘/temp’ 2022-05-21T06:32:20.187841+00:00
    app[web.1]: at Object.mkdirSync (node:fs:1349:3)
    2022-05-21T06:32:20.187842+00:00 app[web.1]: at checkAndMakeDir
    (/app/node_modules/express-fileupload/lib/utilities.js:144:38)
    2022-05-21T06:32:20.187842+00:00 app[web.1]: at module.exports
    (/app/node_modules/express-fileupload/lib/tempFileHandler.js:14:3)
    2022-05-21T06:32:20.187842+00:00 app[web.1]: at Busboy.
    (/app/node_modules/express-fileupload/lib/processMultipart.js:62:9)
    2022-05-21T06:32:20.187843+00:00 app[web.1]: at Busboy.emit
    (node:events:527:28) 2022-05-21T06:32:20.187843+00:00 app[web.1]: at
    Busboy.emit (/app/node_modules/busboy/lib/main.js:37:33)
    2022-05-21T06:32:20.187844+00:00 app[web.1]: at
    PartStream.
    (/app/node_modules/busboy/lib/types/multipart.js:214:13)
    2022-05-21T06:32:20.187844+00:00 app[web.1]: at PartStream.emit
    (node:events:527:28) 2022-05-21T06:32:20.187845+00:00 app[web.1]: at
    HeaderParser.
    (/app/node_modules/dicer/lib/Dicer.js:50:16)
    2022-05-21T06:32:20.187845+00:00 app[web.1]: at HeaderParser.emit
    (node:events:527:28) 2022-05-21T06:32:20.187846+00:00 app[web.1]: at
    HeaderParser._finish
    (/app/node_modules/dicer/lib/HeaderParser.js:68:8)
    2022-05-21T06:32:20.187846+00:00 app[web.1]: at SBMH.
    (/app/node_modules/dicer/lib/HeaderParser.js:40:12)
    2022-05-21T06:32:20.187847+00:00 app[web.1]: at SBMH.emit
    (node:events:527:28) 2022-05-21T06:32:20.187847+00:00 app[web.1]: at
    SBMH._sbmh_feed (/app/node_modules/streamsearch/lib/sbmh.js:95:16)
    2022-05-21T06:32:20.187847+00:00 app[web.1]: at SBMH.push
    (/app/node_modules/streamsearch/lib/sbmh.js:56:14)
    2022-05-21T06:32:20.187848+00:00 app[web.1]: at HeaderParser.push
    (/app/node_modules/dicer/lib/HeaderParser.js:46:19)
    2022-05-21T06:32:20.187848+00:00 app[web.1]: at Dicer._oninfo
    (/app/node_modules/dicer/lib/Dicer.js:196:25)
    2022-05-21T06:32:20.187848+00:00 app[web.1]: at SBMH.
    (/app/node_modules/dicer/lib/Dicer.js:126:10)
    2022-05-21T06:32:20.187849+00:00 app[web.1]: at SBMH.emit
    (node:events:527:28) 2022-05-21T06:32:20.187849+00:00 app[web.1]: at
    SBMH._sbmh_feed (/app/node_modules/streamsearch/lib/sbmh.js:120:12)
    2022-05-21T06:32:20.187849+00:00 app[web.1]: at SBMH.push
    (/app/node_modules/streamsearch/lib/sbmh.js:56:14)
    2022-05-21T06:32:20.187850+00:00 app[web.1]: at Dicer._write
    (/app/node_modules/dicer/lib/Dicer.js:108:17) {
    2022-05-21T06:32:20.187850+00:00 app[web.1]: errno: -2,
    2022-05-21T06:32:20.187850+00:00 app[web.1]: syscall: ‘mkdir’,
    2022-05-21T06:32:20.187850+00:00 app[web.1]: code: ‘ENOENT’,
    2022-05-21T06:32:20.187851+00:00 app[web.1]: path: ‘/temp’
    2022-05-21T06:32:20.187851+00:00 app[web.1]: }
    2022-05-21T06:32:20.313497+00:00 heroku[web.1]: Process exited with
    status 1 2022-05-21T06:32:20.375267+00:00 heroku[web.1]: State
    changed from up to crashed 2022-05-21T06:32:20.399779+00:00
    heroku[router]: at=error code=H13 desc=”Connection closed

without response” method=POST path=”/api/v1/signup” host=sharmastoreapi.herokuapp.com request_id=c5c93945-beac-4a4f-88a1-d8c36711fec8 fwd=”49.36.235.255″ dyno=web.1 connect=0ms service=434ms status=503 bytes=0 protocol=https

How to host Socket io web appplication on heroku

I am trying to host the web application on heroku but every time it shows page not found.
i have followed all the steps of the documentation but all in vain. Please help.

I am enclosing the code files. please let me know if there is any problem in it my heroku url is https://shrouded-fortress-31591.herokuapp.com/

package.json

{
    "name": "nodeserver",
    "version": "1.0.0",
    "description": "Chat application",
    "main": "index.js",
    "scripts": {

        "test": "echo "Error: no test specified" && exit 1",
        "devStart": "nodemon index.js",
        "start": "node index.js"
    },
    "author": "Vedant",
    "license": "ISC",
    "dependencies": {
        "express": "^4.18.1",
        "nodemon": "^2.0.16",
        "socket.io": "^4.5.0",
        "ws": "^8.6.0"
    }
}

client.js

const io = require('socket.io')(process.env.PORT || 8000, {
    cors: {
        origin: '*',
    }
});


const users = {};

io.on('connection', socket => {
    socket.on('new-user-joined', name => {
        console.log("New User", name);
        users[socket.id] = name;
        socket.broadcast.emit('user-joined', name);

    });

    socket.on('send', message => {
        socket.broadcast.emit('receive', { message: message, name: users[socket.id] })
    });
    socket.on('disconnect', message => {
        socket.broadcast.emit('left', users[socket.id]);
        delete users[socket.id];
    });
})

server.js

const socket = io('https://shrouded-fortress-31591.herokuapp.com/');

const form = document.getElementById('sending');
const messageInput = document.getElementById('messageInp');
const messageContainer = document.querySelector(".container");
var audio = new Audio('message.mp3');
const append = (message, position) => {
    const messageElement = document.createElement('div');
    messageElement.innerText = message;
    messageElement.classList.add('message');
    messageElement.classList.add(position);
    messageContainer.append(messageElement);
    if (position == 'left') {
        audio.play();
    }

}



form.addEventListener('submit', (e) => {
    e.preventDefault();
    const message = messageInput.value;
    append(`You: ${message}`, 'right')
    socket.emit('send', message);
    messageInput.value = '';
})
const name = prompt("Enter your name to join");
socket.emit('new-user-joined', name);

socket.on('user-joined', name => {
    append(`${name} joined the chat`, 'right');
})

socket.on('receive', data => {
    append(`${data.name}: ${data.message}`, 'left');
})
socket.on('left', name => {
    append(`${name} left the chat`, 'right');
})

index.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TeamChat-Realtime Chat APP</title>
    <script defer src="https://shrouded-fortress-31591.herokuapp.com/socket.io/socket.io.js"></script>
    <script defer src="client.js"></script>
    <link rel="icon" type="image/x-icon" href="icon.png">
    <link rel="stylesheet" href="style.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@300&display=swap" rel="stylesheet">
</head>

<body>
    <nav>
        <img class="logo" src="icon.png" alt="">
        <h1 class="heading" style="font-family: 'Ubuntu', sans-serif;">TeamChat-Connecting to your favorite ones</h1>
    </nav>

    <div class="container">

    </div>

    <div class="send">
        <form action="#" id="sending">
            <input type="text" name="messageInp" id="messageInp">
            <button class="btn" type="submit">Send</button>
        </form>
    </div>

</body>

</html>

how can i extract a result from array in javaScript?

`window.onload = function() {
    $.ajax({
        url : "/auctionCount.kh",
        data:{memberNo:memberNo},
        success : function(list){
            for(let i=0;i<list.length;i++){
                console.log(list[i]);
            }
        }
    });
};`

enter image description here

I got it as a hashmap type in sql.

I need to extract divno, prevcount, projectname, projectno, viewdif, viewcount separately here but I don’t know how

Validating a select menu

Good morning everyone, please am trying to validate a select menu in the sense a value cannot be selected twice in the options and I did know how to go about it, am stucked and ideas will be highly appreciated

why here i am not getting scroll event , but click event is firing may be something i am doing wrong

So here is the code and I want to get the scroll event object on the scroll of div which content is a lot so div becomes scrollable how we can get scroll event and why its not working

import React from "react";

function App() {
  return (
    <div onScroll={(e) => console.log(e)}>
      Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore, facilis
      magni d.......
      ...............
      vero!
    </div>
  );
}

export default App;

how javascript to jquery

const boxes = document.querySelectorAll(‘.box’)

window.addEventListener(‘scroll’, checkBoxes)

checkBoxes()

function checkBoxes() {

const triggerBottom = window.innerHeight / 5 * 4



boxes.forEach(box => {

    const boxTop = box.getBoundingClientRect().top



    if(boxTop < triggerBottom) {

        box.classList.add('show')

    } else {

        box.classList.remove('show')

    }

})

}

I cant get the value from selected option, what is wrong with these?

<select id="region_id" onChange="get_region_id()" class="form-control">
  <option disabled selected>--Choose Region--</option>

  <?php foreach($region as $row){?>
  <option value="<?php  $row['region_c'];?>">
    <?php echo $row['region_m'];?>
  </option>
  <?php }?>

</select>
<?php ?> -----------------------

<script type="text/javascript">
  function get_region_id() {

    var select = document.getElementById('region_id');
    var options = select.options[select.selectedIndex].value;

    alert(options);
  }
  get_region_id();
</script>

how to set remaining values to last slots

Divide all the total seating capacities during the selected start and end time equally among the slots created. But, if some capacities
are exceeding the rounding values then distribute/divide the slot seating capacities to the last slots.
Example: User has selected the start time as tomorrow at start time 11:00 and end time as 11:45. And the total seating capacity as 6.
So, the 15 mins slots will be created as:

Timing Seating Capacity
11:00 – 11:15 1
11:15 – 11:30 1
11:30- 11:45 2
11:45 – 12:00 2

I need the above result. I have done it using the below code, but no success.

const timePair = timePairs(
      calculate(
        '11:00',
        '12:00'
      )
    );
    console.log(timePair);
    if (timePair.length === values.capacity) {
      console.log(
        map(timePair, (element) => extend({}, element, { capacity: 1 }))
      );
    } else if (values.capacity < timePair.length) {
      console.log(
        map(timePair, (element) =>
          extend({}, element, { capacity: 1 })
        ).slice(0, values.capacity)
      );
    } else {
      if (timePair.length === 1) {
        console.log(
          map(timePair, (element) =>
            extend({}, element, { capacity: values.capacity })
          )
        );
      } else if (timePair.length < values.capacity) {
        console.log(
          map(timePair, (element) =>
            extend({}, element, {
              capacity: Math.round(values.capacity / timePair.length),
            })
          )
        );
      } else {
        const balance = Math.round(values.capacity / timePair.length);
        console.log(balance);
      }
    }

const calculate = (openTime: any, closeTime: any) => {
    const x = {
      slotInterval: 15,
      openTime: openTime,
      closeTime: closeTime,
    };

    const startTime = moment(x.openTime, "HH:mm");
    const endTime = moment(x.closeTime, "HH:mm");

    const allTimes = [];

    while (startTime <= endTime) {
      allTimes.push(startTime.format("HH:mm"));
      startTime.add(x.slotInterval, "minutes");
    }

    return allTimes;
};

const timePairs = (times: any) => {
    const result = [];
    for (let i = 0, n = times.length; i + 1 < n; i += 1) {
      result.push({ start: times[i], end: times[i + 1] });
    }
    return result;
};

The output for the above code is,

[{"start": "11:00", "end": "11:15", "capacity": 2}, {"start": "11:15", "end": "11:30", "capacity": 2}, {"start": "11:30", "end": "11:45", "capacity": 2}, {"start": "11:45", "end": "12:00", "capacity": 2}]

I want the output as (if capacity is 6),

[{"start": "11:00", "end": "11:15", "capacity": 1}, {"start": "11:15", "end": "11:30", "capacity": 1}, {"start": "11:30", "end": "11:45", "capacity": 2}, {"start": "11:45", "end": "12:00", "capacity": 2}]

I want the output as (if capacity is 7),

[{"start": "11:00", "end": "11:15", "capacity": 1}, {"start": "11:15", "end": "11:30", "capacity": 1}, {"start": "11:30", "end": "11:45", "capacity": 2}, {"start": "11:45", "end": "12:00", "capacity": 3}]

comparing arrays in Javascript with index

Say you have, an array and you’re comparing particular elements of that array (with an index) to another array. It returns false although the values of the elements are the same. Why is that?

const arr1 = [1, 3, 5, 7];
[arr1[0], arr1[1]] === [1,3] // false

How to get values of a complex Map and put it into d3.js tooltip of a choropleth?

When creating the tooltip for a barchart I can easily access the “properties” from the data and display it as follow:

...

//append tooltip to div and set its attributes
const TOOLTIP = d3.select("#my-chart")
    .append("div")
    .attr("class", "tooltip");

...

d3.json("storage/data.json").then(function(data) {

...

TOOLTIP.html("<strong>" + d.ds_charge + "<br>"
                  + d.sg_uf + "</strong> (" + d.nr_round + ")<br><br>" +
    "<strong>" +
        d.nr_candidate + " " + d.nm_candidate + "<br>" +
        // format value to show thousands separator
        // https://github.com/d3/d3-format
        "Votes:</strong> " + d3.format(",")(d.tt_votes_nominals) + " (" + d3.format(".2%")(d.tt_votes_nominals / d.tt_votes) + ")<br><br>" +

        "<strong>" + d.nr_party + " " + d.sg_party +   "</strong> " + d.nm_party + "<br>" +
        d.nm_clgc + "<br>" +
        d.ds_composition + "<br><br>" +
        "<strong>Result:</strong> " + d.ds_sit
                );
...

When trying to do the same in a choropleth I don’t extract the data as in the barchart, but from a Map.

const dataMap = new Map(data
    .filter(obj => obj.nr_party == nr_party && obj.nr_round == 1)
    .map(obj => [
        obj.ibge_uf, {
            sg_uf: obj.sg_uf,
            nr_round: obj.nr_round,
            nr_candidate: obj.nr_candidate,
            tt_votes_nominals: obj.tt_votes_nominals,
            nm_candidate: obj.nm_candidate,
            nr_party: obj.nr_party,
            sg_party: obj.sg_party,
            nm_party: obj.nm_party,
            nm_clgc: obj.nm_clgc,
            ds_composition: obj.ds_composition,
            ds_sit: obj.ds_sit
        }
    ])
);

This gives me the following object:

[
    {
        "key": 1,
        "value": {
            "sg_uf": "BR",
            "nr_round": 1,
            "nr_candidate": 30,
            "tt_votes_nominals": 2679745,
            "nm_candidate": "JOÃO AMOÊDO",
            "nr_party": 30,
            "sg_party": "NOVO",
            "nm_party": "Partido Novo",
            "nm_clgc": "PARTIDO ISOLADO",
            "ds_composition": "NOVO",
            "ds_sit": "NÃO ELEITO"
        }
    },
    {
        "key": 35,
        "value": {
            "sg_ufo": "SP",
            "nr_round": 1,
            "nr_candidate": 30,
            "tt_votes_nominals": 1062118,
            "nm_candidate": "JOÃO AMOÊDO",
            "nr_party": 30,
            "sg_party": "NOVO",
            "nm_party": "Partido Novo",
            "nm_clgc": "PARTIDO ISOLADO",
            "ds_composition": "NOVO",
            "ds_sit": "NÃO ELEITO"
        }
    },
...
   {
        "key": 12,
        "value": {
            "sg_ufo": "AC",
            "nr_round": 1,
            "nr_candidate": 30,
            "tt_votes_nominals": 1990,
            "nm_candidate": "JOÃO AMOÊDO",
            "nr_party": 30,
            "sg_party": "NOVO",
            "nm_party": "Partido Novo",
            "nm_clgc": "PARTIDO ISOLADO",
            "ds_composition": "NOVO",
            "ds_sit": "NÃO ELEITO"
        }
    }
]

How can I extract this info to use it like in the barchart?

The tooltip part of the choropleth code is:

const REGION = d3.selectAll(".region");
REGION
    .on("mouseover", function (d) {
        // MAP REGION OPACITY changes
        d3.select(this)
            .transition()
            .duration(64)
            .style("opacity", .48);

        TOOLTIP
            .style("opacity", 1)
            .attr("sg_uf", d3.select(this).attr("sg_uf"))
            .attr("nm_candidate", d3.select(this).attr("nm_candidate"))
            .attr("tt_votes_nominals", d3.select(this).attr("tt_votes_nominals"))

        TOOLTIP.html("<strong>" + d.ds_charge + "<br>"
                          + d.sg_uf + "</strong> (" + d.nr_round + ")<br><br>" +
            "<strong>" +
                d.nr_candidate + " " + d.nm_candidate + "<br>" +
                // format value to show thousands separator
                // https://github.com/d3/d3-format
                "Votes:</strong> " + d3.format(",")(d.tt_votes_nominals) + " (" + d3.format(".2%")(d.tt_votes_nominals / d.tt_votes) + ")<br><br>" +

                "<strong>" + d.nr_party + " " + d.sg_party +   "</strong> " + d.nm_party + "<br>" +
                d.nm_clgc + "<br>" +
                d.ds_composition + "<br><br>" +
                "<strong>Result:</strong> " + d.ds_sit
        );
    })

This is giving me a undefined error.