Crypto.getRandomValues() not supported

I am geting the this error when I run my expo app

crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported

the app starts and later crashes with this error and I can’t seem to figure out where it could be coming from because everything seemed to be working fine earlier. I have deleted node modules and re installed with npm install but error persists. it crashes on the login screen actually so here is the loginScreen.js

import React, { Component, useState } from 'react'
import { SafeAreaView, Button, TextInput, View, Text, 
TouchableOpacity, Alert, KeyboardAvoidingView } from 'react-native'

import AsyncStorage from '@react-native-async-storage/async-storage';


import firebase from 'firebase/compat/app'

import { getAuth, signInWithEmailAndPassword, sendPasswordResetEmail,
setPersistence, inMemoryPersistence, reactNativeLocalPersistence,browserSessionPersistence,
Persistence,} from 'firebase/auth';

import { NavigationContainer } from '@react-navigation/native';


export class Login extends Component {

constructor(props) {

    super(props);
    
   this.state = {
    email: '',
    password: '',
    logingPending: false,
    //userData: {}
   }
   this.onSignIn = this.onSignIn.bind(this)
   this.onResetPassword = this.onResetPassword.bind(this)
};

 async setPersistence(persistence) {
  const  Persistence = persistence
    ? browserSessionPersistence
    : inMemoryPersistence;

  await setPersistence(this.auth, type);
}

onResetPassword() {
  const auth = getAuth();
  const { email, password, logingPending } = this.state
  if(email.trim().length == 0){
    Alert.alert(
      "",
      "please provide your email ",
      [
        
        { text: "OK", onPress: () => this.setState({logingPending:false}) }
      ])
  }else {
sendPasswordResetEmail(auth, email)
.then(() => {
console.log ('')

Alert.alert(
  "",
  "Password reset email sent to ",
  [
    
    { text: "OK", onPress: () => this.setState({logingPending:false}) }
  ])

})
 .catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;

Alert.alert(
  "",
 errorMessage,
  [
    
    { text: "OK", onPress: () => this.setState({logingPending:false}) }
  ])


});
}}


onSignIn(props) {
    const auth = getAuth();
      const { email, password, logingPending } = this.state
      //logingPending: true

      if(email.trim().length == 0 && password.trim.length == 0){
        this.setState({logingPending:false})
        Alert.alert(
          "",
          "Fields can't be empty",
          [
            
            { text: "OK", onPress: () => this.setState({logingPending:false}) }
          ])
        //return
     }else {


      signInWithEmailAndPassword( auth, email, password)
      .then((result) => {

        
       // this.setState({logingPending:false})
        //this.props.navigation.goBack()
      })
      .catch((error) => {
        console.log(error)


       Alert.alert(
           "Login Error",
             'Please confirm your details',
             [
    
                { text: "OK", onPress: () => this.setState({logingPending:false}) }
            ])   
        this.setState({logingPending:false})
        //Alert.alert(error)
        
      })
    } 
}

async storeToken(user) {
  try {
     await AsyncStorage.setItem("userData", JSON.stringify(user));
  } catch (error) {
    console.log("Something went wrong", error);
  }
}


render() {
return (
  <SafeAreaView style = {{ backgroundColor:'lightgray', height:'100%'}}>
    <View style={{
    backgroundColor:'white',
     padding:10,
     margin:10, 
     borderRadius:10,
     minHeight:'50%',
     marginTop: 20
     }}>
  

    <Text style = {{fontSize: 30, 
      fontWeight: 'bold',
       color: 'green', 
       marginBottom: 30}}> Login </Text>


      <View style={{margin: 10,
       backgroundColor:'lightgray',
       borderRadius:10}}>
        {/* <MateriaIcons name='email' size={20} color='#666' style={{marginLeft: 5}} /> */}
        <TextInput style={{borderRadius: 5,
         marginLeft:20,
         marginRight:20, 
         padding: 15,
         color:'black',
         fontWeight: 'bold',
         marginTop: 2
         }} placeholder='email address' autoCorrect={false} onChangeText={(email) => this.setState({email})}  
        keyboardType ='email-address'
        />
      </View>

      <View style={{margin: 10,
       backgroundColor:'lightgray',
       borderRadius:10}}>
        {/* <MateriaIonicons name='ios-lock-closed-outline' size={20} color='#666' style={{marginLeft: 5}} /> */}
        <TextInput style={{borderRadius: 5,
         marginLeft:20,
         marginRight:20, 
         padding: 15,
         color:'black',
         fontWeight: 'bold',
         marginTop: 2
         }} placeholder='password' autoCapitalize={'none'} autoCorrect={false} onChangeText={(password) => this.setState({password})} secureTextEntry= {true} 
        />
    
      
       
        </View>

        <TouchableOpacity style={{marginLeft:'70%', marginTop: 10}}
        onPress={() => {() => onResetPassword()}}>
          <Text style ={{color: 'red'}}>Forgot Password</Text>
        </TouchableOpacity>

        <TouchableOpacity onPress={() => {this.onSignIn(), this.setState({logingPending:true})} } style = {{
          backgroundColor: 'green',
          padding: 20,
          borderRadius: 10,
          marginTop: 20
        }}>
          <Text style={{textAlign: 'center', fontWeight: '700', fontSize: 16, color: '#fff'}}> Login </Text>
        </TouchableOpacity>

        <View style = {{flexDirection: 'row', justifyContent: 'center', marginTop: 30}}>
      <Text>
        Not yet a customer?
      </Text>

      <TouchableOpacity onPress={ () => {
        this.props.navigation.navigate("Register")
      }}>
        <Text style={{color: 'green', fontWeight: '700'}}> JOIN!</Text>
      </TouchableOpacity>
      </View>
      </View>
      
  </SafeAreaView>
)
 }
}

export default Login

Google Maps javascript: issue with custom markers appearing on wrong positions

I’m using google maps javascript to render custom markers on my map, right now all my markers appear to be floating on the wrong positions, all of them aligned on a vertical line, one below another (check image), I don’t know what is happening and tried with chatgpt to fix but no luck.

When I move around on the map the markers are moved to the same position on the screen so they are always floating on the middle of the screen…

Image: https://i.imgur.com/INxOcj9.png

My vue.js component :

<template>
    <div style="width:100%; height:100vh; display:flex; align-items:center; justify-content:center; position:relative; overflow:hidden;">
      <div v-if="!googleMapsLoaded" style="width:100%; height:100%; display:flex; align-items:center; justify-content:center; position:absolute; top:0px; left:0px; overflow:hidden;">
        <i class="fas fa-circle-notch fa-pulse fs_bigger c_secondary" style="margin:0px 0px 0px 0px;"></i>
      </div>
      <div :id="id" class="GOOGLEmap1"></div>
    </div>
  </template>
  
  <script>
  export default {
    name: 'GoogleMap1',
  
    data() {
      return {
        map: null,
        googleMapsLoaded: false,
        markers: [], // Store custom markers
        mapInteracted: false, // Flag to track user interaction
      };
    },
  
    props: {
      id: { default: 'map', type: String },
      places: { type: Array, required: true }
    },
  
    mounted() {
      console.log(this.$options.name + ' component successfully mounted');
      this.initMap();
    },
  
    watch: {
      places: {
        deep: true,
        handler(newPlaces) {
          if (!this.googleMapsLoaded) return;
          this.clearMarkers();
  
          // Only fitBounds if the user has not interacted with the map yet
          if (!this.mapInteracted) {
            this.fitBounds();
          }
  
          newPlaces.forEach(place => {
            this.createCustomMarker(place);
          });
        }
      }
    },
  
    methods: {
      // Check if the map is fully loaded
      checkMapLoaded() {
        google.maps.event.addListener(this.map, 'tilesloaded', () => {
          this.googleMapsLoaded = true;
          console.log('Google Maps loaded successfully');
  
          // Add markers once map is ready and fit the map bounds
          this.places.forEach(place => {
            this.createCustomMarker(place);
          });
          if (!this.mapInteracted) {
            this.fitBounds();
          }
        });
      },
  
      // Initialize the map with options
      initMap() {
        const myOptions = {
          zoom: 15,
          center: new google.maps.LatLng(this.places[0].coordinates.lat, this.places[0].coordinates.lng),
          streetViewControl: false,
          mapTypeControl: false,
          scaleControl: false,
          zoomControl: true // Keep zoom control for better UX
        };
  
        this.map = new google.maps.Map(document.getElementById(this.id), myOptions);
  
        // Detect user interaction with the map (pan or zoom)
        google.maps.event.addListener(this.map, 'bounds_changed', () => {
          this.mapInteracted = true; // Once user moves/zooms, stop calling fitBounds
        });
  
        this.checkMapLoaded(); // Check if the map is loaded before adding markers
      },
  
      // Create custom markers with your specified layout
      createCustomMarker(place) {
        if (!this.googleMapsLoaded) {
          console.log('Google Maps is not yet loaded. Cannot add markers.');
          return;
        }
  
        const position = new google.maps.LatLng(place.coordinates.lat, place.coordinates.lng);
  
        // Create the HTML content for the custom marker
        const markerContent = document.createElement('div');
        markerContent.innerHTML = `
          <div class="shadow" style="width:95px; height:95px; border-radius:50%; border:2px solid white; display:flex; align-items:center; justify-content:center; position:relative;">
            <div style="background-image:url('${place.images[0]}'); width:90px; border:2px solid white; height:90px; border-radius:50%; display:flex; align-items:center; justify-content:center; position:relative; background-size:cover; background-position:center;"></div>
            <div class="bc_secondary" style="width:30px; height:30px; display:flex; align-items:center; justify-content:center; position:absolute; bottom:-5px; right:-5px; border-radius:50%;">
              <span class="fs_normal semi_bold c_light">${place.id}</span>
            </div>
          </div>
        `;
  
        // Add click event listener to the custom marker
        markerContent.addEventListener('click', () => {
          alert(`Clicked on place with ID: ${place.id}`);
        });
  
        // Use OverlayView to add the custom marker to the map
        const overlay = new google.maps.OverlayView();
        overlay.onAdd = function() {
          const panes = this.getPanes();
          panes.overlayMouseTarget.appendChild(markerContent);
        };
  
        overlay.draw = function() {
          const projection = this.getProjection();
          const positionPixel = projection.fromLatLngToDivPixel(position);
  
          if (positionPixel) {
            // Center the marker based on its width (95px)
            markerContent.style.left = `${positionPixel.x - (95 / 2)}px`; 
            markerContent.style.top = `${positionPixel.y - (95 / 2)}px`; 
          }
        };
  
        overlay.setMap(this.map);
  
        // Save the marker reference
        this.markers.push(overlay);
      },
  
      // Fit map bounds to show all markers
      fitBounds() {
        const bounds = new google.maps.LatLngBounds();
        this.places.forEach(place => {
          bounds.extend(new google.maps.LatLng(place.coordinates.lat, place.coordinates.lng));
        });
        this.map.fitBounds(bounds);
      },
  
      // Clear markers from the map
      clearMarkers() {
        this.markers.forEach(marker => {
          marker.setMap(null);
        });
        this.markers = []; // Clear the markers array
      }
    }
  };
  </script>
  
  <style scoped>
  .GOOGLEmap1 {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0px;
    left: 0px;
    z-index: 9;
  }
  </style>
  

How to submit with enter in html?

I am trying to let people rate participants different words with a continuous rating scale and submit when they found are happy with their chosen position. Here is my code to do so:

<main class="content-horizontal-center content-vertical-center">
    <div>

        <div class="m-l" style="height: 200px">
            <p class="font-weight-bold">
                ${parameters.word}
            </p>
            <p class="m-l" style="height: 100px">
                ${parameters.Bewertung}
            </p>
            <form id="pumps-form">
                <input
                        type="range"
                        name="pumps" id="pumps"
                        class="w-100"
                        min="1" max="100" step="1"
                        value="0"
                >
            </form>
        </div>
    </div>
</main>

<div>
    <input type="submit" form="pumps-form"/>
</div>

The submission of the form works fine when they press a button at the bottom of the page. However, I would like to enable to submit the rating with a keyboard buttonpress.

I have tried to use accesskey and the code mentioned here: Submitting a form by pressing enter without a submit button

Also I trie to wrap the input with a form tag (Input submit with enter) which did not work either.

but both did not let me submit my code with a buttonpress.

Thank you!

FlatMap vs Reduce for extracting data from a nested object

I have a dataset as such, where there may be multiple testResults array elements, along with there being 1 or many response array elements; and I an wanting to extract all of the potential completionDate values into their own array.

const testResults = [
  {
    "value": {
      "data": {
        "response": [
          {
            "completionDate": "2024-10-10T17:44:00",
          },
          {
            "completionDate": "2024-10-11T17:44:00",
          }
        ]
      }
    }
  },
  ...
];

I’m curious about the most effective/efficient way in which this could be done that is also readable by the rest of my team.

I have plenty of experience with using map and flatMap for things like this but have recently being using reduce more and wonder if one is more advantageous over the other, and if there’s any other method I have not considered.

flatMap

const timestamps = testResults.flatMap(result => 
  result.value.data.response.map(check => check?.completionDate)
);

reduce

const timestamps = testResults.reduce((acc, res) => {
  res.value.data.response.forEach(check => {
    acc.push(check.completionDate);
  });
  return acc;
}, []);

I did put use console.time around each of them and found that

map: 0.103ms

reduce: 0.067ms

Does this really indicate that the reduce is that much more efficient?

Slides stack on page load

I’m facing an issue with slick.js. The snippet I inserted is showing it too, but not as long as it is on my website.

I’ve checked the loading order for slick and the other JS files. And as far as I know, the order should be correct. The only reason I can see is that the slick files and function are loading slower than the content itself.

Things I tried:

  • Loading the slick.js as one of the first files after jQuery
  • Loading it with async
  • Loading the slick.js and its function before the content (which didn’t work at all)

What can I do to avoid this loading issue?

Network Dev-Tool

$(document).ready(function() {
  $('.slide-container').slick({
    slidesToShow: 1,
    slidesToScroll: 1,
    dots: true,
    infinite: true,
    cssEase: 'linear',
    prevArrow: '<button type="button" class="slick-prev"><i class="fa fa-chevron-left" style="font-size: 2rem;"></i></button>',
    nextArrow: '<button type="button" class="slick-next"><i class="fa fa-chevron-right" style="font-size: 2rem;"></i></button>',
    refresh: true
  });
});
.slick-slide {
  position: relative;
}

.customer-slide {
  background: #000;
  height: 96vh !important;
  width: 100%;
}

.slick-prev,
.slick-next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  margin-top: -22px;
  padding: 16px;
  color: #000;
  font-weight: bold;
  font-size: 18px;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;
  user-select: none;
  z-index: 9999;
  background-color: #fff;
  border: none;
}

.slick-next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

.slider-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  text-align: center;
}

.slider-text h1 {
  font-size: 5rem;
  margin: 0;
}

.slick-dots {
  position: absolute;
  bottom: 10px;
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 0;
  margin: 0;
  list-style: none;
}

.slick-dots li {
  margin: 0 5px;
}

.slick-dots li button {
  font-size: 0;
  line-height: 0;
  display: block;
  width: 12px;
  height: 12px;
  padding: 5px;
  cursor: pointer;
  color: transparent;
  border: 0;
  outline: none;
  background: #cecece20;
  border-radius: 50%;
  transition: background 0.3s;
}

.slick-dots li.slick-active button {
  background: #000;
}
<head>
  <link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/npm/[email protected]/slick/slick.css" />
</head>

<body>
  <div class="slide-container mobile">
    <div class="customer-slide">
      <div class="slider-text">
        <h1>Slide 1</h1>
      </div>
    </div>
    <div class="customer-slide">
      <div class="slider-text">
        <h1>Slide 2</h1>
      </div>
    </div>
  </div>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
  <script type="text/javascript" src="//cdn.jsdelivr.net/npm/[email protected]/slick/slick.min.js"></script>
</body>

Why is this codebase failing to run on my computer

Im on mac sequoia 15. I wanted to work with this repo:

https://github.com/matthewp/haunted-starter-app

To make it run locally I did:

1 - git clone https://github.com/matthewp/haunted-starter-app.git
2 - cd haunted-starter-app
3 - npm install
4 - npm i -g http-server
5 - Changed package.json to include "scripts": {"start": "http-server ."}
6 - npm start

which showed the following in the console:

> [email protected] start
> http-server .
Starting up http-server, serving .
http-server version: 14.1.1
http-server settings: 
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none
Available on:
  http://127.0.0.1:8080
  http://192.168.1.100:8080
Hit CTRL-C to stop the server

Then I go with browser to:

http://127.0.0.1:8080
or even
http://192.168.1.100:8080   
or even
http://localhost:8080   

I always see this error in the dev-tools console:

Uncaught SyntaxError: Unexpected token ':' (at haunted.js:21:67)

I tried both with Chrome and Safari. Same result.
The failing row in haunted.js contains this https url:

https://unpkg.com/lit?moduleElementVersions

Could it be the issue? That Im runnig on HTTP locally?
On the other hand, for some reason, even if I go to codesandbox:

https://codesandbox.io/p/sandbox/github/matthewp/haunted-starter-app

I still seem to have the same issue. How is this possible?
I mean, going here directly (note that it is running on https):

https://6y47ko75xz.csb.app/

generate the same error message in my devtools:

Uncaught SyntaxError: Unexpected token ':' (at haunted.js:21:67)

Is there an in-browser E2E testing framework? [closed]

I recently saw unit tests for a basic JS lib (called “t”) running in the browser and wondered if it would be possible to run end-to-end (UI) tests in the same way.

Is there a framework (similar to Chrome’s F12 Recorder) which allows us to run scripts inside our web application’s browser context?

Ideally we would just add a <script> tag to reference the framework and then one or more <script> tags which run stuff like:

click('#someElement');
let res = await element('#someOtherElement');
assert(res.getAttribute('foo'), 'bar');

Note: Although QUnit does provide DOM plugins, it is explicitly a unit testing framework and I want to test my entire app in the browser.

How to test if child component was clicked?

I need to test (not trigger) if a click is done inside or outside a child component, including the DOM elements from this child and the sub-children.

I was using this code inside the child component with a ref on the main <div>, it works well, but I need the test to be executed from the parent element and it doesn’t work this way :

  mounted() {
    window.addEventListener('click', this.handleClickOutside);
    }
methods: {
    handleClickOutside(event) {
            let targetElement = this.$refs.element;
            if (!targetElement.contains(event.target)) {
                console.log("click")
            }
        },
}

When trying to add the same code in the parent with a ref on the component, I get the error : targetElement.contains is not a function.
I guess this is because the Vue component doesn’t implement the contains method, so is there a way to achieve the same test from the parent side ?

Overlaying a certain column with a blur div to hide the data underneath in Tabulator

I’m looking for advice on creating a blur overlay div to cover a specific column in a table. I want the overlay to show the header while hiding the cells in that column. It’s important that the overlay moves along with resizable columns and persists across pagination changes. How can I ensure the overlay remains in place and resizes properly with the columns? I want to write a text over the blur (so i need an overlayed div element). Think of it like a cover that hides the column underneath. Thank you for your help! I managed to put the overlay div on top of the columns and used

table.on("columnResized", positionOverlay);

yet, with this event, the resize is updated after the mouse movement has ended. It does not simultaneously move with the columns.

And here is my positionOverlay function. Thank you for your help.

    function positionOverlay() {
        const overlay = document.getElementById("overlay");
        const tableElement = document.querySelector(".tabulator-tableholder");
        const column = table.getColumn("someColumn");
        const cellElement = column.getCells()[0]?.getElement();
  
            const rect = cellElement.getBoundingClientRect();
            const tableRect = tableElement.getBoundingClientRect();

            overlay.style.width = rect.width + "px";
            overlay.style.height = tableRect.height + "px";
            overlay.style.left = rect.left + "px";
            overlay.style.top = 34 + "px"; 
            overlay.style.display = "flex";
    }

My frontend is making a ghost calls to my backend

Hope you can help me here this is driving me crazy.

I have a function/route controller in my backend that gets an instagram profile pic:

app.get('/api/instagram/getProfilePic', upload.none(), async (req, res) => {
console.log('/api/instagram/getProfilePic');
console.log(req.query.username);
try {
  const username = req.query.username;
  ...

I call that function/route controller from this function in my frontend:

export const getInstagramProfilePic = async (username) => {
  const cacheName = `ig-profile-pic-${username}`;
  const url = `/api/instagram/getProfilePic?username=${username}`;

  const cachedResponse = await caches.match(url);
  if (cachedResponse) {
    console.log('La imagen está en caché');
    return cachedResponse.url;
  }

  console.log('La imagen debe cargarse desde la red');
  // The execution never reachs this line.
  const response = await fetch(url);

  const responseClone = response.clone();

  const blob = await response.blob();

  caches.open(cacheName).then((cache) => cache.put(url, responseClone));
  return URL.createObjectURL(blob);
};

The thing is that the code never gets to the line where I make the call to the backend which would be this one:

const response = await fetch(url);

Cause it always gets into the if (cachedResponse) section as you can see here:

enter image description here

But even though it never reachs that line I can see in my backend that the execution is going into the route controller /api/instagram/getProfilePic

enter image description here

In my code that link is used just in one place and according to the debugger it never reachs that line:

enter image description here
enter image description here

The point is that I don’t want to use the backend if the image is in my cache so why is going into the backend when the image is in cache already?

Thanks in advance

Accessibility for customized file input

I have this kind of customized file input:

#file-uploader {
  display: none
  }
<input type="file" id="file-uploader" multiple accept=".stl"/>
<label for="file-uploader" role="button" aria-labelledby="drop-file-instructions" tabIndex=0>
  Add files
</label>

I simplified this a lot for the sake of readability, but the problem remains: In this accessibility tree, the label is well detected as a button and focusable but the only way to trigger the file selector is by clicking on the button.

Does anyone have a solution to trigger this by keyboard ?

edit: this is a from a react project, so any react solution is fine with me too

Styles not applying in Material Top Tab Navigator until code changes are made

I’m experiencing an unusual styling issue with React Native’s Material Top Tab Navigator. The styles for my tab contents don’t apply when the app first loads, but they start working when I make any change to the code of that specific tab component.

Here’s the weird behavior:

  1. When app first loads – styles don’t work for either tab
  2. When I edit Tab A’s code – Tab A’s styles work, but Tab B’s styles don’t
  3. When I edit Tab B’s code – Tab B’s styles work, but Tab A’s styles stop working
  4. Restarting the app makes both styles stop working again

Here’s my relevant code:

Parent Component (HistoryScreen.js):

const HistoryScreen = ({ route }) => {
    const { selectedLanguage } = route.params || {};
    const [historyBadgeCount, setHistoryBadgeCount] = useState(0);
    const [notificationsBadgeCount, setNotificationsBadgeCount] = useState(0);

    return (
        <SafeAreaView style={styles.container}>
            <Text style={styles.textHeader}>{texts.historyHeader}</Text>
            <TopTab.Navigator
                screenOptions={{
                    tabBarStyle: styles.tabContainer,
                    tabBarIndicatorStyle: styles.tabIndicator,
                    tabBarActiveTintColor: "#453B44",
                    tabBarInactiveTintColor: "#888",
                    tabBarPressColor: "#e0e0e0",
                }}
            >
                <TopTab.Screen
                    name="History "
                    options={{
                        unmountOnBlur: true,
                        tabBarLabel: ({ focused }) => (
                            <TabLabel label={texts.history} focused={focused} badgeCount={historyBadgeCount} />
                        ),
                    }}
                >
                    {() => <HistoryContent selectedLanguage={selectedLanguage} updateBadgeCount={setHistoryBadgeCount} />}
                </TopTab.Screen>
                <TopTab.Screen
                    name="Notifications "
                    options={{
                        unmountOnBlur: true,
                        tabBarLabel: ({ focused }) => (
                            <TabLabel label={texts.notifications} focused={focused} badgeCount={notificationsBadgeCount} />
                        ),
                    }}
                >
                    {() => <NotificationsContent selectedLanguage={selectedLanguage} updateBadgeCount={setNotificationsBadgeCount} />}
                </TopTab.Screen>
            </TopTab.Navigator>
        </SafeAreaView>
    );
};


Example of one tab content (simplified):

const HistoryTab = ({ selectedLanguage, updateBadgeCount }) => {
    return (
        <View style={styles.container}>
            <FlatList
                data={predictionHistory}
                renderItem={({ item }) => (
                    <View style={styles.element}>
                        <Text style={styles.date}>{date}</Text>
                        {/* Other content */}
                    </View>
                )}
            />
        </View>
    );
};

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: "white",
    },
    element: {
        paddingVertical: height * 0.0125,
        alignSelf: 'center',
        height: height * 0.1375,
        width: width * 0.91,
        marginTop: height * 0.0375,
        borderBottomWidth: 1,
        borderBottomColor: 'rgba(90, 46, 84, 0.2)'
    },
    // other styles...
});

Dependencies:

"@react-navigation/material-top-tabs": "^6.6.5",
"react-native": "0.72.x"
Using "expo": "^51.0.38",

What I've tried: 
Restarting the development server
Clearing cache
Forcing re-render of both tab's contents every time tabs are switched
Many more (been a long time)

Telynx API:Dial – the from_display_name property is not being respected

When using the NodeJs API like so, the from_display_name property is not having any effect on the receiving device. What makes this even stranger is that is was working a few weeks ago. I’m not sure if I changed something and broke this but the customer service reps have not been able to help me track down why the values I’m setting in the from_display_name field is not showing on the receiving mobile device.

Has anyone here worked with this API and this property specifically, I’ve been stuck on this for like a week and like I said their tech support hasn’t been able to help me troubleshoot this to the root.

Yes, it was working at one point – so I know this does work

Please advise, really appreciate the help!

      const newCall = await telnyx.calls.create({
        connection_id: customer.telnyx_connection_id,
        to: customer.phone_number,
        from: customer.telnyx_phone_number,
        from_display_name: `Incoming from ${event.data.payload.from}`,
        answering_machine_detection: 'premium'
      });

Setting the from_display_name property would show up on the receiving device as the from caller on the screen. Suddenly this just stopped working. Currently I’m trying to use the CNAM Listing as advised with a random value. I was told that the value doesn’t matter BUT it being toggled on will register the number with CNAM and allow the value I dynamically set to show up on the device. I was told it would take up to 48 hours to work so I’m currently in the waiting window for this test and will follow up in another 24 hours with the results of this update.

JS library for post reactions like on FB? [closed]

Are there any JS libraries for adding reactions to posts in a form of animated emojis like on Facebook? I can’t find any because words like reaction or post are misinterpreted while searching in this context. I don’t want use React or jQuery. I can build such a functionality by myself but it seems to be pretty common thing so I’m wondering there are some libraries for that.

Why type inference fails

  1. I use ItemMap to map each type to its corresponding item.
 type ItemMap = {
  write: string[];
  see: string[];
  find: DataLibraryType[];
  read: UploadFile[];
};
  1. The generic parameter K of SearchListProps is used to realize that different currentWay corresponds to different list types.
interface SearchListProps<K extends WaysType> {
 currentWay: K;
 list: ItemMap[K];
 onClick: (val: ItemMap[K][number]) => void;
 onRemove?: () => void;
}
type WaysType = 'write' | 'read' | 'see' | 'find'

I want the list to be able to infer different types based on the value of currentWay

But ts error

The parameter “index” implicitly has type “any”, but better types can be inferred from usage. ts(7044)

and When currentWay = ‘read’ , the list type error

error msg : Attribute “name” does not exist on type “string | DataLibraryType | UploadFile” Attribute “name” does not exist on type “string”.

const SearchList = <K extends WaysType>(props: SearchListProps<K>) => {
  const { currentWay, list, onClick, onRemove } = props
  switch (currentWay) {
    case 'write':
    case 'see':
    case 'find':
      return <div>
        {
          list.map((r, index) => {
            const itemName = currentWay === 'find' ? r?.name : r
            return <div key={index}>{itemName}</div>
          })
        }
      </div>
    case 'read':
      const currentFile = list?.[0]
// Attribute “name” does not exist on type “string | DataLibraryType | UploadFile<any>”  Attribute “name” does not exist on type “string”.
      const fileType = getFileExtension(currentFile?.name) || 'file'
      if (!currentFile) {
        return <></>
      }
      return <div>{currentFile?.desc}</div>
    default:
      return <></>
  }
}

I want the list to be able to infer different types based on the value of currentWay

  switch (currentWay) {
    case 'write':
    case 'see':
    case 'find':
      return <div>
        {
          list.map((r, index) => {
            const itemName = currentWay === 'find' ? r?.name : r
            return <div key={index}>{itemName}</div>
          })
        }
      </div>
    case 'read':
        // list type is UploadFile[] no error
    return <div>... </div>