How do I extend the Load JSON example from vasturiano to include images as nodes

On vasturiano’s page about his force-directed HTML5 graph is an example that uses images as nodes in a random graph. I want to extend the example and load my own graph from a JSON file.

In the first example I tried to insert my own images and had success.

https://github.com/vasturiano/force-graph/blob/master/example/img-nodes/index.html

Now I want to extend the following example and load my own graph from a JSON file.

https://github.com/vasturiano/force-graph/blob/master/example/load-json/index.html

With the second example, I had success creating and loading a JSON file, but had no success trying to load custom images and use them in the graph. More specifically, I don’t know what to put in the nodeCanvasObject() function.

How to make sure setInterval doesn’t stack if it is already running?

I have a class with the function start() which generates particles after a given interval, but if you call the start() function more than once, the clearInterval() in the stop() function doesn’t stop it anymore.

Here is the code:

class ParticleGenerator {
  constructor(pgPhyEngine, x, y, width, height, particleSizeRange = {
    min: 3,
    max: 10
  }, spawnRate = 100, particlesPerSpawn = 1, velXRange = {
    min: -15,
    max: 15
  }, velYRange = {
    min: -15,
    max: 15
  }, particleColorsArray = ["#ff8000", "#808080"]) {
    this.parent = pgPhyEngine;
    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;
    this.particleSizeRange = particleSizeRange;
    this.velXRange = velXRange;
    this.velYRange = velYRange;
    this.particleColors = particleColorsArray;
    this.spawnRate = spawnRate;
    this.spawning = false;
    this.particlesPerSpawn = particlesPerSpawn;
  }

  start() {
    this.spawnManager = setInterval(() => {
      for (var i = 0; i < this.particlesPerSpawn; i++) {
        this.parent.createParticle((this.x - this.width / 2) + (random(0, this.width)), (this.y - this.height / 2) + (random(0, this.height)), random(this.particleSizeRange.min, this.particleSizeRange.max), pickRandomItemFromArray(this.particleColors), true, random(this.velXRange.min, this.velXRange.max), random(this.velYRange.min, this.velYRange.max));
      }
    }, this.spawnRate);
  }

  stop() {
    // This doesn't work if the start() function is called more than once.
    clearInterval(this.spawnManager);
  }
}

Not able to update Nested object array in treeview Reactjs

Thanks in advance !!!

Question : I am not able to update nested object of array in treeview Reactjs. Please refer below codesand box link for code

https://codesandbox.io/s/cocky-leakey-ptjt50?file=/src/Family.js

Requirement is that once i have clicked on parent checkbox then child checkbox automatically get selected .Please find below image for reference enter image description here

So if I clicked on the parent i.e “Mammal” then automatically it should select child element like Canidae,Dog, Fox and Wolf.but this code is updating the single value only not nested object.

On click of checkbox I am iterating the nested object using recursion see below code.

const updateObject = (labelkey, objectData, value) => {
    return objectData.map((object) => {
      if (object.label.trim() === labelkey.trim()) {
        object.checked = value;
      } else {
        if (
          object.nodes &&
          object.nodes.length > 0 &&
          typeof object.nodes === "object" &&
          object.nodes !== null
        ) {
          object.nodes = updateObject(labelkey, object.nodes, value);
        }
      }

      return object;
    });
  };
  
  const checkBoxChicked = (label) => {
    var newData = JSON.parse(JSON.stringify(treeData));
  // Calling updateobject method
    const result = updateObject(label.label, newData, !label.checked);
    var resultData = JSON.parse(JSON.stringify(result));

    setTreeData(resultData);
  };
return (
    <div style={{ paddingLeft: "20px" }}>
      {treeData?.map((parent) => {
        return (
          <div key={parent.label}>
            {parent.isFolder && (
              <div className="parent">
                <input
                  type="checkbox"
                  id={parent.label}
                  name={parent.label}
                  value={parent.label}
                  checked={parent?.checked ? parent.checked : false}
                  onClick={() => checkBoxChicked(parent)}
                />
                <label for={parent.label}> {parent.label}</label>
              </div>
            )}
            {/* rendering files */}
            {!parent.isFolder && (
              <div style={{ paddingLeft: "32px" }}>
                <input
                  type="checkbox"
                  id={parent.label}
                  name={parent.label}
                  value="Bike"
                  checked={parent?.checked ? parent.checked : false}
                  onClick={() => checkBoxChicked(parent)}
                />
                <label for={parent.label}>{parent.label}</label>
              </div>
            )}
            {/* Base Condition and Rendering recursive component from inside itself */}
            <div>
              {parent.nodes && parent.nodes.length > 0 && (
                <Family familyTree={parent.nodes} />
              )}
            </div>
          </div>
        );
      })}
    </div>
  );

How to add two screens to the navigation of the React Native app without showing them in the TabBar?

I need the user registration and login screens to not be displayed in the TabBar of the App
I have a simple application in which I am trying to have two types of user interface, one for a guest mode and one for when the user is authenticated.
I have created a navigation for each authentication conditional, so that the TabBar corresponding to each state of the application is displayed, or guest mode or authenticated mode. I also have a TabBar Component to show the Icons of each of the Navigations.

The problem arises when I want to add the LoginScreen and RegisterScreen screens since I can’t access them.

I have tried to create a third Navigation (AuthNavigator ) to manage these screens, and finally got access but they show up on the TabBar,
But this cannot be, these screens cannot be accessed from the TabBar

I need them to be in the navigation, but not show on the TabBar.

In the TabBar file these screens are not added, so the Icon is not shown, but the title is

I have tried using options={{ tabBarVisible: false }} , but this has no effect

Also display = "none" without success.

I have looked for solutions in Google and I have not found anything.

I want to show my navigation system to guide me what I’m doing. wrong and can correct my mistakes.

——— App.js ———

import React from 'react'
import { NavigationContainer } from '@react-navigation/native'
import GuestNavigator from './navigation/GuestNavigator'
import AppNavigator from './navigation/AppNavigator'

const App = () => {
 
  const isUserAuthenticated = false; 

  return (
    <NavigationContainer>
      {isUserAuthenticated ? (
        <AppNavigator />
      ) : (
        <GuestNavigator />
      )}
    </NavigationContainer>
  )
}
export default App 

—This is the navigation in GUEST mode—

—- GuestNavigator.JS ——-

import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import TabBar from '../components/TabBar';

const Tab = createBottomTabNavigator();

const GuestNavigator = ({ handleLogin }) => {
  return (
    <Tab.Navigator tabBar={props => <TabBar {...props} />}>
      <Tab.Screen name="Home" component={HomeScreen} />
      <Tab.Screen name="SampleNotas" component={SampleNotasScreen} />
      <Tab.Screen name="SampleCuras" component={SampleCurasScreen} />
      <Tab.Screen name="SamplePerfil" component={SamplePerfilScreen} />
      <Tab.Screen
        name="Login"
        options={{ tabBarVisible: false }}
        children={() => <LoginScreen handleLogin={handleLogin} />}
      />
    </Tab.Navigator>
  );
};
export default GuestNavigator; 

–This is the navigation in the AUTHENTICATED mode —

—— AppNavigator.JS ———

import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import TabBar from '../components/TabBar';
const Tab = createBottomTabNavigator();

const AppNavigator = () => {
  return (
    <Tab.Navigator tabBar={props => <TabBar {...props} />}>
      <Tab.Screen name="Notas" component={NotasScreen} />
      <Tab.Screen name="CrearNota" component={CrearNotaScreen} options={{ tabBarVisible: false }} />
      <Tab.Screen name="Curas" component={CurasScreen} />
      <Tab.Screen name="Recordatorios" component={RecordatoriosScreen}/>
      <Tab.Screen name="Profile" component={ProfileScreen} />
      <Tab.Screen name="EditProfile" component={EditarProfileScreen} options={{ tabBarVisible: false }} />
    </Tab.Navigator>
  );
};
export default AppNavigator

And I have also created a navigation system only for Login and Register

——- AuthNavigator.js ———-

import React from 'react'
import { NavigationContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
import LoginScreen from '../screens/AuthScreens/LoginScreen'
import RegisterScreen from '../screens/AuthScreens/RegisterScreen'

const Stack = createStackNavigator()

const AuthNavigator = () => {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen
          name="Login"
          component={LoginScreen}
          options={{
            headerShown: false,
          }}
        />
        <Stack.Screen
          name="Register"
          component={RegisterScreen}
          options={{
            title: 'Registro',
          }}
        />
      </Stack.Navigator>
    </NavigationContainer>
  )
}

export default AuthNavigator

Of course if I remove LoginScrein from the GuestNavigator navigation, I get error:

ERROR The action ‘NAVIGATE’ with payload {“name”:”Login”} was not handled by any navigator.
Do you have a screen named ‘Login’?
If you’re trying to navigate to a screen in a nested navigator, see https://reactnavigation.org/docs/nesting-navigators#navigating-to-a-screen-in-a-nested-navigator.
This is a development-only warning and won’t be shown in production.

And I also show the TabBar although it shows the icon and these screens are not added.
—– TabBar.js ———–

import React from 'react';
import { View, TouchableOpacity, Text } from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';

const TabBar = ({ state, descriptors, navigation, isUserAuthenticated }) => {
  return (
    <View style={{ flexDirection: 'row', height: 60, backgroundColor: '#F3F9F5' }}>
      {state.routes.map((route, index) => {
        const { options } = descriptors[route.key];

        const onPress = () => {
          const event = navigation.emit({
            type: 'tabPress',
            target: route.key,
          });

          if (!event.defaultPrevented) {
            navigation.navigate(route.name);
          }
        };

        const isFocused = state.index === index;
        const color = isFocused ? '#08A438' : 'black';

        let iconName;
        if (!isUserAuthenticated) {
          // Iconos para el modo invitado
          if (route.name === 'Home') {
            iconName = 'home';
          } else if (route.name === 'SampleNotas') {
            iconName = 'list';
          } else if (route.name === 'SampleCuras') {
            iconName = 'medkit';
          } else if (route.name === 'SamplePerfil') {
            iconName = 'person';
          }
        } else {
          // Iconos para el modo autenticado
          if (route.name === 'Notas') {
            iconName = 'notes';
          } else if (route.name === 'Curas') {
            iconName = 'medkit';
          } else if (route.name === 'Recordatorios') {
            iconName = 'alarm';
          } else if (route.name === 'Profile') {
            iconName = 'person';
          }
        }

        return (
          <TouchableOpacity
            key={index}
            onPress={onPress}
            style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}
          >
            <Icon name={iconName} size={24} color={color} />
            <Text style={{ color }}>{route.name}</Text>
          </TouchableOpacity>
        );
      })}
    </View>
  );
};
export default TabBar

How to implement a return to telegram after confirming a transaction in the Tonkeeper wallet?

How to implement a return to telegram after confirming a transaction in the Tonkeeper wallet?

I’m using a tonconnect-sdk and sending transactions as stated in the documentation:

connector.sendTransaction({
  validUntil: Math.floor(new Date() / 1000) + 360,
  messages: [
    {
      address: "0:b2a1ecf5545e076cd36ae516ea7ebdf32aea008caa2b84af9866becb208895ad",
      amount: "100000000"
    }
  ]
})

‘IF’ block not displaying properly

I can’t figure out why the if block doesn’t work in this part of the code:

const turnOnNotification = () => {
        const isEventCompleted = moment(eventEnd).isBefore(moment());
        if (isEventCompleted) {
            toast.error(`The ${eventName} event has ended!`);
            ref.current.classList.add(styles.completed);
        } else {
            ref.current.classList.add(styles.notification);
            toast.error(`The ${eventName} event will end soon!`);
        }
      };

It only works on page reload.
Here is the complete code:

import React, { useRef, useEffect, useState } from "react";
import styles from './EventItem.module.sass';
import moment from 'moment';
import { toast } from 'react-toastify';

const EventItem = (props) => {
    const {
        eventName,
        eventStart,
        eventEnd,
        eventNotification,
        eventId,
        userId,
        updateEvents } = props;

    const [editing, setEditing] = useState(false);
    const [editedName, setEditedName] = useState(eventName);
    const [editedStart, setEditedStart] = useState(eventStart);
    const [editedEnd, setEditedEnd] = useState(eventEnd);
    const [completed, setCompleted] = useState(false);

    const ref = useRef(); 

    const turnOnNotification = () => {
        const isEventCompleted = moment(eventEnd).isBefore(moment());
        if (isEventCompleted) {
            toast.error(`The ${eventName} event has ended!`);
            ref.current.classList.add(styles.completed);
        } else {
            ref.current.classList.add(styles.notification);
            toast.error(`The ${eventName} event will end soon!`);
        }
      };

    const deleteEvent = () => {
        const userEvents = JSON.parse(localStorage.getItem(`${userId}`));
        const index = userEvents.findIndex(event => event.eventId === eventId);
        if (index >= 0) {
            userEvents.splice(index, 1);
            localStorage.setItem(`${userId}`, JSON.stringify(userEvents));
        }
        updateEvents();
    }

    const startEditing = () => {
        setEditing(true);
    }

    const cancelEditing = () => {
        setEditing(false);
        setEditedName(eventName);
        setEditedStart(eventStart);
    }

    const saveEditing = () => {
        const userEvents = JSON.parse(localStorage.getItem(`${userId}`));
        const index = userEvents.findIndex(event => event.eventId === eventId);
        if (index >= 0) {
            userEvents[index].eventName = editedName;
            userEvents[index].eventStart = editedStart;
            userEvents[index].eventEnd = editedEnd;
            localStorage.setItem(`${userId}`, JSON.stringify(userEvents));
        }
        setEditing(false);
        updateEvents();
    }

    useEffect(() => {
        console.log("eventEnd value:", eventEnd); // Вставляем консоль для вывода значения eventEnd

        const isEventCompleted = moment(eventEnd).isBefore(moment());
        setCompleted(isEventCompleted);
      
        if (isEventCompleted) {
          turnOnNotification();
        } else {
          const diffNotification = moment(eventNotification).diff(moment());
          const timerNotification = setTimeout(turnOnNotification, diffNotification);
      
          return () => {
            clearTimeout(timerNotification);
          };
        }
      
        if (completed) {
          turnOnNotification();
        }
      }, [eventEnd, eventNotification]);

    return (    
        <>
            <li
                ref={ref}
                className={`${styles.container} ${completed ? styles.completed : ""} ${
                    editing ? styles.editing : ""
                }`}
                >
                <div className={styles.eventBody}>
                    {editing ? (
                        <>
                            <input
                                type="text"
                                value={editedName}
                                onChange={(e) => setEditedName(e.target.value)}
                                className={`${styles.eventTitle} ${styles.input}` }
                            />
                            <input
                                type="datetime-local"
                                value={moment(editedStart).format("YYYY-MM-DDTHH:mm")}
                                onChange={(e) => setEditedStart(e.target.value)}
                                className={styles.eventStart}
                            />
                            <input
                                type="datetime-local"
                                value={moment(editedEnd).format("YYYY-MM-DDTHH:mm")}
                                onChange={(e) => setEditedEnd(e.target.value)}
                                className={styles.eventEnd}
                            />
                        </>
                    ) : (
                        <>
                            <div className={styles.eventTitle}>{eventName}</div>
                            <span>{moment(eventStart).format('DD MMM YYYY HH:mm')}</span>
                            {' '}
                            <span>{moment(eventEnd).format('DD MMM YYYY HH:mm')}</span>
                        </>
                    )}
                </div>
                <div className={styles.actions}>
                    {editing ? (
                        <>
                            <i onClick={saveEditing} className={`fas fa-solid fa-save ${styles.saveIcon}`}></i>
                            <i onClick={cancelEditing} className={`fas fa-solid fa-times ${styles.cancelIcon}`}></i>
                        </>
                    ) : (
                        <i onClick={startEditing} className={`fas fa-solid fa-edit ${styles.editIcon}`}></i>
                    )}
                    <i onClick={deleteEvent} className={`fas fa-solid fa-trash ${styles.deleteIcon}`}></i>
                </div>
            </li>
        </>
    );
}

export default EventItem;

I tried to cast to a date, since the eventEnd gives the type as a string, but it does not help anything.

Does this code run synchronously? Javascript

I understand that Axios runs asynchronously in Javascript. Also, I understand that Axios runs synchronously if I use Axios, async, and await together.

    const test = async () => {
        const first = await axios.get(~~~~~~~~);
        const second = await axios.get(~~~~~~);
        const third = await axios.get(~~~~~);
}

Then in this code, is it correct that the first function is executed and the task is finished, the second function is executed and the task is finished, and then the third is executed?

Sorry for my bad English.

Why I’m getting “Text strings must be rendered within a component”?

I’m making an app with React Native and getting
this error:

Error: Text strings must be rendered within a <Text> component.

code:

  const [childsName, setChildsName] = useState('');
  const [childsNameToBeLinked, setChildsNameToBeLinked] = useState('');
  const [email, setEmail] = useState('');
  const [code, setCode] = useState('');
  const [isParent, setParent] = useState(false);
  const [isChild, setChild] = useState(false);
  const [isLinked, setLinked] = useState(false);
  const [allDoneForParents, setAllDoneForParents] = useState(false);
  const [childsNameAddedNotif, setChildsNameAddedNotif] = useState('');
  const [uri, setUri] = useState('');

  return (
      <View style={styles.container}>
        {!isParent && !isChild && (
          <View>
            <View style={styles.buttonContainer}>
               <Button title="This Is Child's Phone" onPress={() => setChild(true)} />
            </View>
            <View style={styles.buttonContainer}>
              <Button title="This Is Parent's Phone" onPress={() => setParent(true)}  />
            </View>

          </View>
        )}
        {isParent && (
          <View>
            <View style={styles.inputContainer}>
              <TextInput placeholder='@' onChangeText={(val) => setEmail(val)} value={email} />
            </View>
            <View style={styles.inputContainer}>
              <TextInput placeholder='Enter Code' onChangeText={(val) => setCode(val)} value={code} />
            </View>
            {childsNameAddedNotif && (
              <View>
                <Text>{childsNameAddedNotif}'s Phone Has Been Linked</Text>
              </View>
            )}
            {!childsNameAddedNotif && (
              <View style={styles.submitBtn}>
                <Button title='Submit' onPress={handleSubmit} />
              </View>
            )}
            
            <View style={styles.backBtnContainer}>
              <BackBtn onPress={() => setParent(false)} />
            </View>
          </View>
        )}
        {isChild && !isLinked && !code && (

              <View>
                <View style={styles.inputContainer}>
                  <TextInput placeholder="Child's First Name" onChangeText={(val) => setChildsName(val)} value={childsName} />
                </View>
                <View style={styles.submitBtn}>
                  <Button title='Submit' onPress={handleSubmit} />
                </View>
                <View style={styles.backBtnContainer}>
                  <BackBtn onPress={() => setChild(false)} />
                </View>
              </View>
          )}
        {isChild && !isLinked && code && (
              <View>
                <Text>OK, now use your phone, tap on This Phone Parent's Phone, enter your email and {code}</Text>
              </View>
          )}
        {isLinked && !allDoneForParents && (
          <View>
            <View>
              <Text>{childsNameToBeLinked}'s Phone Is Now Linked</Text>
              <Text>Would You Like To Link More Children ?</Text>
            </View>
            <View>
              <Button title='Yes' onPress={() => setLinked(false)} />
            </View>
            <View>
              <Button title='No' onPress={() => setAllDoneForParents(true)} />
            </View>
          </View>
        )}
        {allDoneForParents && (
          <View>
            <Text>All Done For You Now. Little Angel Will Notify You If Needed.</Text>
            <Text>Have a Nice Day :) </Text>
          </View>
        )}

      <StatusBar style="auto" />
    </View>

  );
}

Can you see where my strings aren’t within the Text component ?

Next.js: Facebook pixel is not fired after router.push()

I have some FB pixel code inside

<Script id="some-id" strategy="afterInteractive">some fb pixel code</Script>

The problem is when I navigate to page with script via router.push(SOME_ROUTE)
the event is not fired. I’ve managed to fix this making router.reload and after that everything fires correctly, but gives not the best user experience because of reload.

Any explanation why FB Pixel not fires after router.push?

Plot generation using MNE In DJANGO

I am working on a Django project, the work revolves around raw eeg signal acquisition from a Muse headset. The signal acquisition is being done in the frontend in a file that I bundle with the html. After signal acquisition the data is sent to the backend, converted to a csv file and saved on my machine. Now I need to take this file and use the MNE library for pre-processing and show relevant plots on the frontend. What would be the best/usual way to do this?

Expecting to get the right plots.

Server 404 NodeJs

I created a server and connected it with MongoDB when I made an API in the index.js File, it is coming, but when I created an function for the same and made an API in another file and exported to index.js Its coming 404 server error

This is my index.js file

import express from "express";
import Connection from "../backend/connection.js";
import dotenv from "dotenv";
import calling from "./data/routes/route.js";

dotenv.config();
const USERNAME = process.env.DB_USERNAME;
const PASSWORD = process.env.DB_PASSWORD;

const PORT = 5000;
const app = express();
app.listen(PORT, () => {
  console.log(`Server Started on Port ${PORT}`);
});

Connection(USERNAME, PASSWORD);

calling();

This is my route.js file

import express from "express";

const app = express();

const calling = () => {
  app.get("/blogs", (req, res) => {
    res.send("Yes");
  });
};

export default calling;

Here is the pic of the error

enter image description here

Tried to surf in google but not found anything

How can i use vue-virtual-scroller with vue use useInfiniteScroll?

I’m currently working on implementing infinite scroll in a Vue application using the `useInfiniteScroll` function from `@vueuse/core`. However, I’m facing an issue with binding the `ref` to the scrollable element. The infinite scroll functionality is not working as expected. The `useInfiniteScroll` callback function is not triggered when scrolling near the bottom of the element. I am using vue-virtual-scroller package(https://github.com/Akryum/vue-virtual-scroller/tree/master) for virtual list

I have followed the steps mentioned in the documentation and made sure that:

  • The “ref is correctly defined using the `ref` function in my JavaScript code.

  • The “ref is assigned to the scrollable element within the “DynamicScroller.e-solution-list__body component, which I’m using in my template.

Here’s my code:

<template lang="pug">
DynamicScroller.e-solution-list__body(:items="items" :min-item-size="54" v-if="items.length && !solutionTable.loading" :emit-update="true" ref="scroller")
        template(#default="{ item, index, active }")
          DynamicScrollerItem(:item="item" :active="active" :data-index="index")
            .e-solution-list__row(:key="item.id" :class="{ 'e-solution-list__row--expanded': isExpanded(item.id), 'e-solution-list__row--mobile-border': !isExpanded(item.id) || !item.tags.length }")
</template>
<script lang="ts">
import { useInfiniteScroll } from '@vueuse/core'
 setup(props) {
    const columns = ref(SOLUTION_COLUMNS)
    const id = ref(props.problemId)
    const solutionTable = reactive({
      loading: false,
      loadMore: false,
      data: [],
      totalCount: 0,
      query: {
        sortBy: '-createdDate',
        skip: 0,
        limit: USE_CASE_LIMIT,
        text: '',
        popPaths: 'solutionProviderList,actors,sfCategories,sfSubCategories,sfIndustries,sfTechnologies,sfTags'
      }
    })
    const scroller = ref<HTMLElement>(null)
 //infinite scroll
    nextTick(() => {
      useInfiniteScroll(
        scroller,
        () => {
          getRelatedSolutions({
            skip: items.value.length,
            limit: USE_CASE_LIMIT,
            loadMore: true,
            isScrollTop: false,
            sortBy: sortBy.isAscending ? sortBy.key : `-${sortBy.key}`
          })
        },
        {
          distance: ITEM_HEIGHT * 2
        }
      )
    })

    
}


</script>

Despite following these steps, the infinite scroll functionality is not working as expected. The `useInfiniteScroll` callback function is not triggered when scrolling near the bottom of the element. I have tried the following approaches, but none of them resolved the issue:

  1. Ensuring the `ref` is properly assigned within the `DynamicScroller.e-solution-list__body` component.

  2. Accessing the scrollable element using `document.getElementById()` or `document.querySelector()` instead of a `ref`.

  3. Wrapping the `useInfiniteScroll` call in the `$nextTick` function to ensure the DOM is updated.

I would appreciate any insights or suggestions on how to troubleshoot this issue and get the infinite scroll working correctly. Thank you!

Next.JS dynamic meta tags

I added some dynamic meta tags for a page in my next.js application.

import CoinTossPage from '@/views/CoinTossPage';
import React, { useEffect, useState } from 'react';
import Head from 'next/head';
import { useRouter } from 'next/router';
import axios from 'axios';

function CoinTossComponent() {
  const router = useRouter();
  const { id } = router.query;
  const [poolData, setPoolData] = useState(null);

  useEffect(() => {
    if (id) {
      fetchPoolData();
    }
  }, [id]);

  // fetch pool data from API using pool id
  const fetchPoolData = async () => {
    try {
      let config = {
        method: 'get',
        url: `${process.env.NEXT_PUBLIC_API_BASE_URL}/api/v1/gambling/coin-flip/pool/${id}`,
        headers: {
          Authorization: `Bearer ${process.env.NEXT_PUBLIC_API_KEY}`,
        },
      };
      const response = await axios(config);
      if (response.status === 200) {
        const payload = response.data.payload;
        if (payload) {
          setPoolData(payload);
        } else {
          setPoolData(null);
        }
      }
    } catch (error) {
      console.log('ERROR while fetching active pools from API ', error);
    }
  };

  return (
    <>
      <Head>
        <meta property="og:title" content={poolData?.tokenSymbol} />
        <meta property="og:image" content={poolData?.imageUrl} />
      </Head>
      <CoinTossPage />
    </>
  );
}

export default CoinTossComponent;

This is how it is added and, this is how it appear when I look it on page inspect.

enter image description here

It’s clearly showing the dynamic content in meta tags. But when I share the page link, this image is not appearing.

What is the issue?

I tried reading their documentation https://nextjs.org/learn/seo/rendering-and-ranking/metadata and added meta tags according to it.

Animate element position in received one via web sockets using JS and CSS

The feature is to draw the cars moving by track. Track shape is simplified to circle. I receive the data via web sockets ~5 frames per second. In every frame I receive the pecentage driven by track per moment for every car and depending on this value I move the car on the circle.

It works well, but movement looks ‘sharply’ and I need to smooth the movement as if it is a real car moving. I will be grateful for any suggestion or adviceThis is the track circle