React Native new Architecture problem with Codegen

Im with react native 0.71.0 new Architecture but facing the issue with Codegen :

1: Task failed with an exception.

  • What went wrong:
    Execution failed for task ‘:react-native:ReactAndroid:buildCodegenCLI’.

A problem occurred starting process ‘command ‘…/node_modules/@react-native/codegen/scripts/oss/build.sh”

Here is my settings.gradle file

rootProject.name = 'XXX'
   include ':app'
includeBuild('../node_modules/react-native-gradle-plugin')
if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") {
    include(":ReactAndroid")
    project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid')
    include(":ReactAndroid:hermes-engine")
    project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine')
}
includeBuild('../node_modules/react-native') {
dependencySubstitution {
         substitute(module("com.facebook.react:react-android")).using(project(":ReactAndroid"))
         substitute(module("com.facebook.react:react-native")).using(project(":ReactAndroid"))
         substitute(module("com.facebook.react:hermes-android")).using(project(":ReactAndroid:hermes-engine"))
         substitute(module("com.facebook.react:hermes-engine")).using(project(":ReactAndroid:hermes-engine"))
        //  substitute(module("com.facebook.react:react-native-gradle-plugin")).using(project(":"))
     }
 }
include ':@react-native-community_datetimepicker'
project(':@react-native-community_datetimepicker').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/datetimepicker/android')
include ':@react-native-community_datetimepicker'
project(':@react-native-community_datetimepicker').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/datetimepicker/android')
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':rn-fetch-blob'
project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android')
include ':react-native-is-device-locked'
project(':react-native-is-device-locked').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-is-device-locked/android')
include ':react-native-otp-verify'
project(':react-native-otp-verify').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-otp-verify/android')
include ':react-native-otp-verify'
project(':react-native-otp-verify').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-otp-verify/android')

// apply from: '../node_modules/react-native-unimodules/gradle.groovy'
// includeUnimodulesProjects()
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
useExpoModules()

// apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesSettingsGradle(settings)

include ':app'

apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()

Changed newArchEnabled=true in gradle.properties

Added “react-native-codegen”: “^0.71.5” under devDependencies in package.json

Here is my app/build.gradle

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
import com.android.build.OutputFile
react {
}


project.ext.react = [
    enableHermes: true,
    entryFile: "index.js",
    bundleInDebug: true,
    bundleInRelease: false,
    cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/cli.js",
    hermesCommand: '../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc',
    composeSourceMapsPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/scripts/compose-source-maps.js",
]

apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../react.gradle")

project.ext.vectoricons = [
    iconFontNames: [ 'MaterialIcons.ttf', 'Ionicons.ttf' ] 
]

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

def enableSeparateBuildPerCPUArchitecture = false


def enableProguardInReleaseBuilds = false


def jscFlavor = 'org.webkit:android-jsc:+'


def enableHermes = project.ext.react.get("enableHermes", true);
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim());
                configurations.all {
        resolutionStrategy {
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
    }
}

android {
    compileSdkVersion 33

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    defaultConfig {
        applicationId 'xxx.xxx.xxx'
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 9
        versionName "1.0.2"
    }

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
        kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

      applicationVariants.all { variant ->
        variant.outputs.each { output ->
      
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }
    }
    packagingOptions {
        pickFirst '**/*.so'
        pickFirst '**/libc++_shared.so'
        pickFirst '**/libfbjni.so'
        pickFirst 'lib/armeabi-v7a/your_name.so'
        pickFirst 'lib/arm64-v8a/your_name.so'
        pickFirst 'lib/x86/your_name.so'
        pickFirst 'lib/x86_64/your_name.so'
    }
     ndkVersion '24.0.8215888'

    dexOptions {
        incremental true
    }
    }

dependencies {
     // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")

    implementation fileTree(dir: "libs", include: ["*.jar"])
       
    def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
    def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
    def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";

    if (isGifEnabled || isWebpEnabled) {
        implementation 'com.facebook.fresco:fresco:2.0.0'
        implementation 'com.facebook.fresco:imagepipeline-okhttp3:2.0.0'
    }

    if (isGifEnabled) {
        // For animated gif support
        implementation 'com.facebook.fresco:animated-gif:2.0.0'
    }

    if (isWebpEnabled) {
        // For webp support
        implementation 'com.facebook.fresco:webpsupport:2.0.0'
        if (isWebpAnimatedEnabled) {
            // Animated webp support
            implementation 'com.facebook.fresco:animated-webp:2.0.0'
        }
    }

    implementation platform('com.google.firebase:firebase-bom:31.2.3')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.facebook.soloader:soloader:0.10.5'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'com.google.firebase:firebase-appcheck-safetynet:16.1.2'
    debugImplementation("com.facebook.flipper:flipper:0.185.0") {
      exclude group:'com.facebook.fbjni'
    }
    debugImplementation("com.facebook.flipper:flipper-network-plugin:0.185.0") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }
    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:0.182.0") {
        exclude group:'com.facebook.flipper'
    }
    
    if (enableHermes) {
        debugImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-debug.aar"))
        releaseImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-release.aar"))
    } else {
        implementation jscFlavor
    }
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.api
    into 'libs'
}

apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'

Not able to proceed further with the build due to the error. Any update on the same would be highly appreciated.

what to do about ‘aw snap, something went wrong while displaying this page, Error code: STATUS_BREAKPOINT’ error in js

my javascript game was working this morning, and then I added some code and got this:‘aw snap, something went wrong while displaying this page, Error code: STATUS_BREAKPOINT’. I deleted the code that i added but the error still came up.

after i changed my code back and it still didn’t work, i did some internet research and here is what i tried (to no avail):

restarting my computer,

clearing my cache and cookies,

trying on a different web browser,

opening Devtools (it said that devtools was disconnected).

getting off school wifi in case they blocked it

i am using an online code editor and i tried running some of my other programs on it and they still worked. i also tried downloading the project and trying without my code editor. that didn’t work either.
my code is quite long but i will add the link to the game.

link: https://arcade-quest.botman101.repl.co

Setting inputs as values from a string of GET request parameters with JS?

We want to set various inputs to the values contained in a str inputValueStr obtained like so:

  const form = document.querySelector('#theForm');
  var object = Object.values(form).reduce((obj, field) => { obj[field.name] = field.value; return obj }, {});
  delete object[""];
  const inputValuesStr =  new URLSearchParams(object).toString()

The string looks like “foo=&bar=123&baz=examplestr&whatever=”. What’s a good way to set the #theForm‘s inputs to the values from the string (ie. make inputs of bar = 123, baz = “examplestr”, and other inputs null)?

We’re unsure if we’re missing something as we don’t know what to search for so apologies if this is a stupid question. If so please feel free to redirect us to another thread.

how to display input box in alert and pass the value to next page in php

i have a php website, where there is a table, when user clicks on the button in any column an alert will popup and should show an input box, when the user enters any value, i should get it in next page, i did the following:

<a href="<?php echo base_url('admin_works/generateinvoice/'.$val['id']);?>" onclick="return confirm('Are you sure you want to generate invoice?');" style="margin-left:7%">
  <i class="fa fa-key" aria-hidden="true" style="color:orange"></i>
</a>

please let me know how to accomplish this, thanks in advance

How to upload header logo dynamically based on page url in WordPress

I am new in WordPress I have below requirement .

  • Need to call rest api to get logo url based on dynamic page url (https://xyz/image1/).

  • After receiving image url want to upload dynamically in header section.

I just created custom theme as per my requirement but not sure with best approach to call rest api dynamically to receive dynamically logo.

Thanks in advance for help.

How do I add new nodes and edit the node or delete it for this treeview using javascript/jaquery

$.fn.extend({
    treed: function (o) {

      var openedClass = 'fa-minus-circle';
      var closedClass = 'fa-plus-circle';

      if (typeof o != 'undefined'){
        if (typeof o.openedClass != 'undefined'){
        openedClass = o.openedClass;
        }
        if (typeof o.closedClass != 'undefined'){
        closedClass = o.closedClass;
        }
      };

        //initialize each of the top levels
        var tree = $(this);
        tree.addClass("tree");
        tree.find('li').has("ul").each(function () {
            var branch = $(this); //li with children ul
            branch.prepend("<i class='indicator fas " + closedClass + "'></i>");
            branch.addClass('branch');
            branch.on('click', function (e) {
                if (this == e.target) {
                    var icon = $(this).children('i:first');
                    icon.toggleClass(openedClass + " " + closedClass);
                    $(this).children().children().toggle();
                }
            })
            branch.children().children().toggle();
        });
        //fire event from the dynamically added icon
      tree.find('.branch .indicator').each(function(){
        $(this).on('click', function () {
            $(this).closest('li').click();
        });
      });
        //fire event to open branch if the li contains an anchor instead of text
        tree.find('.branch>a').each(function () {
            $(this).on('click', function (e) {
                $(this).closest('li').click();
                e.preventDefault();
            });
        });
        //fire event to open branch if the li contains a button instead of text
        tree.find('.branch>button').each(function () {
            $(this).on('click', function (e) {
                $(this).closest('li').click();
                e.preventDefault();
            });
        });
    }
});

//Initialization of treeviews

$('#tree1').treed();

$('#tree2').treed({openedClass:'fa-folder-open', closedClass:'fa-folder'});
.tree, .tree ul {
  margin:0;
  padding:0;
  list-style:none;
  margin-left:10px;
}
.tree ul {
  margin-left:1em;
  position:relative
}
.tree ul ul {
  margin-left:.5em
}
.tree ul:before {
  content:"";
  display:block;
  width:0;
  position:absolute;
  top:0;
  bottom:0;
  left:0;
  border-left:1px solid
}
.tree li {
  margin:0;
  padding:0 1em;
  line-height:2em;
  color:#369;
  font-weight:700;
  position:relative;
}
.tree ul li:before {
  content:"";
  display:block;
  width:10px;
  height:0;
  border-top:1px solid;
  margin-top:-1px;
  position:absolute;
  top:1em;
  left:0
}
.tree ul li:last-child:before {
  background:#fff;
  height:auto;
  top:1em;
  bottom:0
}
.indicator {
  margin-right:5px;
}
.tree li a {
  text-decoration: none;
  color:#369;
}
.tree li button, .tree li button:active, .tree li button:focus {
  text-decoration: none;
  color:#369;
  border:none;
  background:transparent;
  margin:0px 0px 0px 0px;
  padding:0px 0px 0px 0px;
  outline: 0;
}
<div class="row">
    <div class="col-md-4">
       <ul id="tree2">
          <li>
             <a href="#">TECH</a>
             <ul>
                <li>Company Maintenance</li>
                <li>
                   Employees
                   <ul>
                      <li>
                         Reports
                         <ul>
                            <li>Report1</li>
                            <li>Report2</li>
                            <li>Report3</li>
                         </ul>
                      </li>
                      <li>Employee Maint.</li>
                   </ul>
                </li>
                <li>Human Resources</li>
             </ul>
          </li>
          <li>
             XRP
             <ul>
                <li>Company Maintenance</li>
                <li>
                   Employees
                   <ul>
                      <li>
                         Reports
                         <ul>
                            <li>Report1</li>
                            <li>Report2</li>
                            <li>Report3</li>
                         </ul>
                      </li>
                      <li>Employee Maint.</li>
                   </ul>
                </li>
                <li>Human Resources</li>
             </ul>
          </li>
          
       </ul>
    </div>
 </div>
   <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script>

I have this menu, I am trying to add new nodes to it with the ability to delete / edit these nodes, but I have no idea about that. Please help me as much as possible,

and i want to create data o information into into hierarchical format.there would be a single root element and n number parents and childs.The Parent can have a leaf element or element that have another child leaf.

What is being passed as ‘e’ in the handleAdd prop function?

Basically i am trying to pass the e from the map function that I’m using. I am not sure if that’s the e that’s being passed in the handleAdd prop function. And console.log(e) in handleAdd prop function, its giving me the value in the value prop of the <ItemQuantity/> component. I’m confused. What is the behaviour here?

          <Stack direction="column">
            {cartItems.length > 0
              ? cartItems.map((e) => {
                  return (
                    <Box
                      display="flex"
                      alignItems="flex-start"
                      padding="1rem"
                      key={e._id}
                    >
                      <Box className="image-container">
                        <img
                          // Add product image
                          src={`${e.image}`}
                          // Add product name as alt eext
                          alt={`${e.name}`}
                          width="100%"
                          height="100%"
                        />
                      </Box>
                      <Box
                        display="flex"
                        flexDirection="column"
                        justifyContent="space-between"
                        height="6rem"
                        paddingX="1rem"
                      >
                        <div>{`${e.name}`}</div>
                        <Box
                          display="flex"
                          justifyContent="space-between"
                          alignItems="center"
                        >
                          <ItemQuantity
                            // Add required props by checking implementation
                            value={e.quantity}
                            handleAdd={(e) => {addButton(e)}}
                          />
                          <Box padding="0.5rem" fontWeight="700">
                            ${`${e.cost}`}
                          </Box>
                        </Box>
                      </Box>
                    </Box>
                  );

<!-- begin snippet: js hide: false console: true babel: false -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

Function doesn’t add decimal dot to a string

I’m building calculator app and i got a problem with setting a decimal dot. Integer function doesnt add a dot to a number blockA or blockB.

let strOfNum = [];
let blockA = 0;
let blockB = "";
let curOperator = "";
let prevOperator = "";
let coma = "";

function integer(integers) {
  if (curOperator) {
    blockB += integers;
    blockB = Number(blockB);
    display.textContent = blockB;
  } else {
    blockA += integers;
    blockA = Number(blockA);
    display.textContent = blockA;
  }
}
function setDecimal() {
  if (!coma) {
    integer(".");
    display.textContent = ".";
    decimal = ".";
  }
}

OnClick Handler overwriting previous value if using same handler for multiple DOM elements

import React, { useState, useEffect } from "react";

const Swatches = (props) => {
  const options = props.options;
  const label = Object.keys(options);
  const values = Object.values(options);
  const colors = props.colors;
  const sizes = props.sizes;
  let selected = [];
  let a = {};
  const selecetedOption = (e) => {
    selected.push({
      option_id: e.target.dataset.id,
      option_value: e.target.dataset.value,
    });

    let result = [];
    selected.map((y) => {
      let index = result.findIndex((x) => x.option_id === y.option_id);
      if (index == -1) {
        result.push({ option_id: y.option_id, option_value: y.option_value });
      } else {
        result[index].option_value = y.option_value;
      }
    });
    console.log(result);
  };

  return (
    <React.Fragment>
      {values.length > 0 && (
        <div>
          <div className="flex middle-xs mb-15">
            <div className="fs-16 fw-5 c-main-gray">
              Pick your <span className="option-label">{label}</span>
            </div>
          </div>
          {label == "color" && colors?.options?.length > 0 && (
            <div className="flex flex-wrap size-unit-list">
              {colors?.options?.map((option, index) => (
                <React.Fragment key={index}>
                  {values[0].indexOf(parseInt(option.value)) > -1 && (
                    <div
                      className="fs-14 fw-5 c-dark-gray ta-c pt-6 pb-6 pl-10 pr-10 mw-40 mb-10 b-light-gray b-box size-button br-3 pos-relt mr-r-10 h-33 w-33"
                      style={{ backgroundColor: option?.label }}
                      data-id={colors.id}
                      data-value={option.value}
                      role="button"
                      onClick={selecetedOption}
                    ></div>
                  )}
                </React.Fragment>
              ))}
            </div>
          )}
          {label == "size" && sizes?.options?.length > 0 && (
            <div className="flex flex-wrap size-unit-list">
              {sizes?.options?.map((option, index) => (
                <React.Fragment key={index}>
                  {values[0].indexOf(parseInt(option.value)) > -1 && (
                    <div
                      className="fs-14 fw-5 c-dark-gray ta-c pt-6 pb-6 pl-10 pr-10 mw-40 mb-10 b-light-gray b-box size-button br-3 pos-relt mr-r-10"
                      data-id={sizes.id}
                      data-value={option.value}
                      role="button"
                      onClick={selecetedOption}
                    >
                      <span className="lh-ar-2 en-font">{option.label}</span>
                    </div>
                  )}
                </React.Fragment>
              ))}
            </div>
          )}
        </div>
      )}
    </React.Fragment>
  );
};

export default Swatches;

When I and clicking on first element its working fine but when I click on second element and call onClick={selecetedOption} it overwrite previous values of result array and start it all over again.

Actual Result
when I click on colors, console.log(result) giving below
[ { "option_id": "159", "option_value": "167" } ]
but when i click on size, console.log(result) is giving
[ { "option_id": "93", "option_value": "59" } ]

Expected Result
When i Click on colors
[ { "option_id": "159", "option_value": "167" } ]

when i click on sizes It should be like below
[ { "option_id": "159", "option_value": "167" }, { "option_id": "93", "option_value": "59" } ]

How can I dispatch a custom event from a Web Component and catch it in a React Functional Component and use it?

What could I be doing wrong? I am dispatching a custom event called “select-date” from a custom web component date picker and am not sure whether it’s reaching the React functional component that consumes it. The issue is that it’s not logging as expected when I test it. Find my code below:

What I have tried and where I have consulted includes ChartGPT, a few other tutorials related to this and other related issues here Stackoverflow, but at least to no avail yet!

import { Calendar, Day } from ".";

class DatePicker extends HTMLElement {
  
  constructor() {
     super();

     //...
  }

   attributeChangedCallback(name: string, oldValue: any, newValue: any) {
    //...
  }

  connectedCallback() {
    this.mounted = true;

    //...
  }
  
  emitSelectDateEvent(dateTile: HTMLButtonElement) {
    if (parseInt(dateTile.innerHTML) === this.date.date) {
      const event = new CustomEvent("select-date", {
        detail: this.date,
      });
      this.dispatchEvent(event);
      // event tested and emitting event well.
      console.log(event);
    }
  }

  selectDay(dateTile: HTMLButtonElement, day: any) {
    //.... Other code here
    this.emitSelectDateEvent(dateTile);
  }

  
  updateMonthDays() {

    this.getMonthDaysGrid().forEach((day: any) => {
      const newDateTile = document.createElement("button");
      newDateTile.textContent = day.date;
      newDateTile.addEventListener("click", () =>
        this.selectDay(newDateTile, day)
      ); 
    });
  }

}

And the FormField component consuming the date picker web component below:


import {
  ChangeEventHandler,
  DOMAttributes,
  HTMLInputTypeAttribute,
  MutableRefObject,
  useEffect,
} from "react";
import { Calendar, DatePicker } from "../date-picker";
import Card from "../cards/Card";

/** A Web Component Custom DatePicker */
type CustomElement<T> = Partial<T & DOMAttributes<T> & { children: any }>;

declare global {
  namespace JSX {
    interface IntrinsicElements {
      ["date-picker"]: CustomElement<DatePicker>;
    }
  }
}

type FormFieldProps = {
  cols?: number;
  element: string;
  fieldRef: MutableRefObject<any>;
  fileName?: any;
  handleInputClick?: () => void | undefined;
  icon: any;
  id: string;
  label?: string;
  labelRef: MutableRefObject<any>;
  name: string;
  rows?: number;
  step: string[];
  type?: HTMLInputTypeAttribute;
  value?: string;
  onInputChange?: ChangeEventHandler<HTMLInputElement> | undefined;
  onTextAreaChange?: ChangeEventHandler<HTMLTextAreaElement> | undefined;
};

const FormField = ({
  element,
  fieldRef,
  handleInputClick,
  id,
  name,
  onInputChange,
  type,
  value,
}: FormFieldProps) => {
    

  useEffect(() => {
    const datePicker = document.querySelector("date-picker");
    datePicker?.addEventListener("select-date", handleSelectDate);

    console.log(datePicker); // Tested and logged the date picker.

    return () => {
      datePicker?.removeEventListener("select-date", handleSelectDate);
      console.log("Dismounted Custom Event Listener..."); 
    };
  }, []);

  const handleSelectDate = (event: CustomEventInit): void => {
    // NOT BEING REACHED!!
    console.log(
      "select-date event received in Calendar component with date:",
      event.detail
    );
    // setSelectedDate(selectedDate); 
    // ...rest of the code
  };

  const cal = new Calendar();
  // console.log(cal.getPreviousMonth());

  /**
   * Main return call in switch statement */
  switch (element) {
    case "input":
      return (
        <Card
          className={
            name === "art"
              ? "art-wrapper input-wrapper"
              : name === "song"
              ? "input-wrapper song-wrapper"
              : name === "submit"
              ? "input-wrapper submit-wrapper"
              : "input-wrapper"
          }
          handleClick={handleClick}
          name={name}
          renderFileName={renderFileName}
        >
          <label
            className={
              name === "art"
                ? "song-art-label"
                : name === "song"
                ? "track-label"
                : undefined
            }
            htmlFor={id}
          >
            
            <input
              id={id}
              hidden={name === "art" ? true : name === "song" ? true : false}
              name={name}
              onBlur={handleFocusBlur}
              onChange={
                name === "art" || name === "song"
                  ? handleFieldChange
                  : onInputChange
              }
              onClick={name === "releaseYear" ? handleInputClick : undefined}
              onFocus={handleFocusBlur}
              ref={fieldRef}
              type={type}
              value={value}
            />
            

            {name === "releaseYear" && (
              <date-picker
                format={"MMM DD (DDD), YYYY"}
                date={"01-01-2023"}
                position={"top"}
                visible
              ></date-picker>
            )}
          </label>
        </Card>
      );
    case "textarea":
      return (
        <label className="" htmlFor={id}>
          {/** unrelated code */}          
        </label>
      );
    default:
      return null;
  }
};

export default FormField;

Pure JavaScript Binance price API WebSocket example [closed]

I’m looking for a very simple, pure JavaScript, Binance price API, WebSocket code, working example without using any additional frameworks like Angular, etc. and without the use of node.js and no Typescript either please.

I simply need a blank html page with a simple live price action and nothing else, if it’s possible to do in a clean and bare minimum code.

This is the API json link:
https://data.binance.com/api/v3/ticker/price?symbol=BTCUSDT

React router dom when i click view frontend button to application.js page

in dashboard page in have view frontend button if i click button its move to application.js page how to write code pls help…..

in dashboard page in have view frontend button if i click button its move to application.js page how to write code pls help…..

in dashboard page in have view frontend button if i click button its move to application.js page how to write code pls help…..

in dashboard page in have view frontend button if i click button its move to application.js page how to write code pls help…..

in dashboard page in have view frontend button if i click button its move to application.js page how to write code pls help…..

in dashboard page in have view frontend button if i click button its move to application.js page how to write code pls help…..

dashboard.js

import "./dashboard.css";

function Dashboard(){
    
    return(
        <>
        <div className="dimg">
            <img src="./Logoimg/washigniter.png" alt="Companylogo"/>
        </div>
        <div className="navbar">
                <ul>
                    <li>Dashboard</li>
                    <li>Vehicle Type</li>
                    <li>Service List</li>
                    <li>Packages</li>
                    <li>Booking</li>
                    <li>Payments</li>
                    <li>Out of Service</li>
                    <li>Reports</li>
                    <li>Integration</li>
                    <li>Settings</li>
                </ul>
        </div>
        <div className="header">
            <button>View Frontend</button>
            <select>
                <option>admin</option>
                <option>Setting</option>
                <option>Profile</option>
                <option>Logout</option>
            </select>
        </div>
        <div className="header2">
            <h3>Dashboard</h3>
            <h4><span>Dashboard </span>/ Dashboard</h4>
        </div>
        
        </>
    )
}
export {Dashboard};

application.js

import "./application.css";
import { useState } from "react";


function Application(){
    const [clickedButton, setClickedButton] = useState('Yet to Choose..');

    const handleButtonClick = (value) => {
        setClickedButton(value);
    }

    const [clickedButtons, setClickedButtons] = useState('Yet to Choose..');

    const handleButtonClicks = (value) => {
        setClickedButtons(value);
    }

    const [clickedsButtons, setClickedsButtons] = useState('Yet to Choose..');

    const handlesButtonClicks = (value) => {
        setClickedsButtons(value);
    }

    const [total, setTotal] = useState(0);

    const handleClick = (value) => {
        setTotal(prevTotal => prevTotal + value);
    }

    return(
        <>
        <div className="header">
            <img className="aimg" src="./Logoimg/washigniter.png" alt="Comapanylogo"/>
        </div>
        <div className="box1">
            <h3>Service Category</h3>
            <h1 className="listno1">1<span>/5</span></h1>
            <div>
            <h1 className="category1">Category</h1>
            <h4 className="category11">Select service category below</h4>
            </div>
            <button className="ss1" onClick={() => handleButtonClick("Car Wash")}>
                <img className="aimg1" src="./Logoimg/washimg.jpg" alt="Washimg"/>
            </button>
            <button className="ss2" onClick={() => handleButtonClick("Car Wrapping")}>
                <img className="aimg2" src="./Logoimg/wrapimg.jpeg" alt="Wrapimg"/>
            </button>
        </div>

        <div className="box2">
            <h3>Service List</h3>
            <h1 className="listno2">2<span>/5</span></h1>
            <div>
                <h1 className="category2">Services</h1>
                <h4 className="category22">Select services below</h4>
            <div className="service1">
                <div className="service11">
                    <h4 className="sh1">Engine oil change</h4>
                    <h4 className="sh2">1hr Mins</h4>
                    <h4 className="sh3">Price:<span> 999</span></h4>
                    <button onClick={() => handleClick(999)}>Select</button>
                </div>
                <h5 className="sh4">oil change</h5>
                <hr className="hr2"></hr>
            </div>

            <div className="service2">
                <div className="service22">
                    <h4 className="sh11">Water wash</h4>
                    <h4 className="sh22">10Mins</h4>
                    <h4 className="sh33">Price:<span> 499</span></h4>
                    <button onClick={() => handleClick(499)}>Select</button>
                </div>
                <h5 className="sh4">car wash</h5>
                <hr className="hr2"></hr>
            </div>

            <div className="service3">
                <div className="service33">
                    <h4 className="sh111">Washigniter</h4>
                    <h4 className="sh222">9hr Mins</h4>
                    <h4 className="sh333">Price:<span> 10000</span></h4>
                    <button onClick={() => handleClick(10000)}>Select</button>
                </div>
                <h5 className="sh4">https://www.igi-global.com/dictionary/cloud-service-brokerage/26600#:~:text=A definition of what a,or rules for its usage.</h5>
                <hr className="hr2"></hr>
            </div>

        </div>

        <div className="box3">
            <h3>Date & Time</h3>
            <h1 className="listno3">3<span>/5</span></h1>
            <div>
                <h1 className="category3">Block your time slot</h1>
                <h4 className="category33">Select date & time below</h4>
            </div>

            <div className="dt">
                <h3>Mar-21</h3>
                <h3>Mar-22</h3>
                <h3>Mar-23</h3>
                <h3>Mar-24</h3>
                <h3>Mar-25</h3>
                <h3>Mar-26</h3>
                <h3>Mar-2</h3>
                <button onClick={() => {handleButtonClicks("11.00AM"); handlesButtonClicks("2023-03-21")}}>11.00AM</button>
                <button onClick={() => {handleButtonClicks("11.00AM"); handlesButtonClicks("2023-03-22")}}>11.00AM</button>
                <button onClick={() => {handleButtonClicks("11.00AM"); handlesButtonClicks("2023-03-23")}}>11.00AM</button>
                <button onClick={() => {handleButtonClicks("11.00AM"); handlesButtonClicks("2023-03-24")}}>11.00AM</button>
                <button onClick={() => {handleButtonClicks("11.00AM"); handlesButtonClicks("2023-03-25")}}>11.00AM</button>
                <button onClick={() => {handleButtonClicks("11.00AM"); handlesButtonClicks("2023-03-26")}}>11.00AM</button>
                <button onClick={() => {handleButtonClicks("11.00AM"); handlesButtonClicks("2023-03-27")}}>11.00AM</button>
                <button onClick={() => {handleButtonClicks("11.30AM"); handlesButtonClicks("2023-03-21")}}>11.30AM</button>
                <button onClick={() => {handleButtonClicks("11.30AM"); handlesButtonClicks("2023-03-22")}}>11.30AM</button>
                <button onClick={() => {handleButtonClicks("11.30AM"); handlesButtonClicks("2023-03-23")}}>11.30AM</button>
                <button onClick={() => {handleButtonClicks("11.30AM"); handlesButtonClicks("2023-03-24")}}>11.30AM</button>
                <button onClick={() => {handleButtonClicks("11.30AM"); handlesButtonClicks("2023-03-25")}}>11.30AM</button>
                <button onClick={() => {handleButtonClicks("11.30AM"); handlesButtonClicks("2023-03-26")}}>11.30AM</button>
                <button onClick={() => {handleButtonClicks("11.30AM"); handlesButtonClicks("2023-03-27")}}>11.30AM</button>
                <button onClick={() => {handleButtonClicks("12.00PM"); handlesButtonClicks("2023-03-21")}}>12.00PM</button>
                <button onClick={() => {handleButtonClicks("12.00PM"); handlesButtonClicks("2023-03-22")}}>12.00PM</button>
                <button onClick={() => {handleButtonClicks("12.00PM"); handlesButtonClicks("2023-03-23")}}>12.00PM</button>
                <button onClick={() => {handleButtonClicks("12.00PM"); handlesButtonClicks("2023-03-24")}}>12.00PM</button>
                <button onClick={() => {handleButtonClicks("12.00PM"); handlesButtonClicks("2023-03-25")}}>12.00PM</button>
                <button onClick={() => {handleButtonClicks("12.00PM"); handlesButtonClicks("2023-03-26")}}>12.00PM</button>
                <button onClick={() => {handleButtonClicks("12.00PM"); handlesButtonClicks("2023-03-27")}}>12.00PM</button>
                <button onClick={() => {handleButtonClicks("12.30PM"); handlesButtonClicks("2023-03-21")}}>12.30PM</button>
                <button onClick={() => {handleButtonClicks("12.30PM"); handlesButtonClicks("2023-03-22")}}>12.30PM</button>
                <button onClick={() => {handleButtonClicks("12.30PM"); handlesButtonClicks("2023-03-23")}}>12.30PM</button>
                <button onClick={() => {handleButtonClicks("12.30PM"); handlesButtonClicks("2023-03-24")}}>12.30PM</button>
                <button onClick={() => {handleButtonClicks("12.30PM"); handlesButtonClicks("2023-03-25")}}>12.30PM</button>
                <button onClick={() => {handleButtonClicks("12.30PM"); handlesButtonClicks("2023-03-26")}}>12.30PM</button>
                <button onClick={() => {handleButtonClicks("12.30PM"); handlesButtonClicks("2023-03-27")}}>12.30PM</button>
                <button onClick={() => {handleButtonClicks("1.00PM"); handlesButtonClicks("2023-03-21")}}>1.00PM</button>
                <button onClick={() => {handleButtonClicks("1.00PM"); handlesButtonClicks("2023-03-22")}}>1.00PM</button>
                <button onClick={() => {handleButtonClicks("1.00PM"); handlesButtonClicks("2023-03-23")}}>1.00PM</button>
                <button onClick={() => {handleButtonClicks("1.00PM"); handlesButtonClicks("2023-03-24")}}>1.00PM</button>
                <button onClick={() => {handleButtonClicks("1.00PM"); handlesButtonClicks("2023-03-25")}}>1.00PM</button>
                <button onClick={() => {handleButtonClicks("1.00PM"); handlesButtonClicks("2023-03-26")}}>1.00PM</button>
                <button onClick={() => {handleButtonClicks("1.00PM"); handlesButtonClicks("2023-03-27")}}>1.00PM</button>
                <button onClick={() => {handleButtonClicks("1.30PM"); handlesButtonClicks("2023-03-21")}}>1.30PM</button>
                <button onClick={() => {handleButtonClicks("1.30PM"); handlesButtonClicks("2023-03-22")}}>1.30PM</button>
                <button onClick={() => {handleButtonClicks("1.30PM"); handlesButtonClicks("2023-03-23")}}>1.30PM</button>
                <button onClick={() => {handleButtonClicks("1.30PM"); handlesButtonClicks("2023-03-24")}}>1.30PM</button>
                <button onClick={() => {handleButtonClicks("1.30PM"); handlesButtonClicks("2023-03-25")}}>1.30PM</button>
                <button onClick={() => {handleButtonClicks("1.30PM"); handlesButtonClicks("2023-03-26")}}>1.30PM</button>
                <button onClick={() => {handleButtonClicks("1.30PM"); handlesButtonClicks("2023-03-27")}}>1.30PM</button>
                <button onClick={() => {handleButtonClicks("2.00PM"); handlesButtonClicks("2023-03-21")}}>2.00PM</button>
                <button onClick={() => {handleButtonClicks("2.00PM"); handlesButtonClicks("2023-03-22")}}>2.00PM</button>
                <button onClick={() => {handleButtonClicks("2.00PM"); handlesButtonClicks("2023-03-23")}}>2.00PM</button>
                <button onClick={() => {handleButtonClicks("2.00PM"); handlesButtonClicks("2023-03-24")}}>2.00PM</button>
                <button onClick={() => {handleButtonClicks("2.00PM"); handlesButtonClicks("2023-03-25")}}>2.00PM</button>
                <button onClick={() => {handleButtonClicks("2.00PM"); handlesButtonClicks("2023-03-26")}}>2.00PM</button>
                <button onClick={() => {handleButtonClicks("2.00PM"); handlesButtonClicks("2023-03-27")}}>2.00PM</button>
                <button onClick={() => {handleButtonClicks("2.30PM"); handlesButtonClicks("2023-03-21")}}>2.30PM</button>
                <button onClick={() => {handleButtonClicks("2.30PM"); handlesButtonClicks("2023-03-22")}}>2.30PM</button>
                <button onClick={() => {handleButtonClicks("2.30PM"); handlesButtonClicks("2023-03-23")}}>2.30PM</button>
                <button onClick={() => {handleButtonClicks("2.30PM"); handlesButtonClicks("2023-03-24")}}>2.30PM</button>
                <button onClick={() => {handleButtonClicks("2.30PM"); handlesButtonClicks("2023-03-25")}}>2.30PM</button>
                <button onClick={() => {handleButtonClicks("2.30PM"); handlesButtonClicks("2023-03-26")}}>2.30PM</button>
                <button onClick={() => {handleButtonClicks("2.30PM"); handlesButtonClicks("2023-03-27")}}>2.30PM</button>
                <button onClick={() => {handleButtonClicks("3.00PM"); handlesButtonClicks("2023-03-21")}}>3.00PM</button>
                <button onClick={() => {handleButtonClicks("3.00PM"); handlesButtonClicks("2023-03-22")}}>3.00PM</button>
                <button onClick={() => {handleButtonClicks("3.00PM"); handlesButtonClicks("2023-03-23")}}>3.00PM</button>
                <button onClick={() => {handleButtonClicks("3.00PM"); handlesButtonClicks("2023-03-24")}}>3.00PM</button>
                <button onClick={() => {handleButtonClicks("3.00PM"); handlesButtonClicks("2023-03-25")}}>3.00PM</button>
                <button onClick={() => {handleButtonClicks("3.00PM"); handlesButtonClicks("2023-03-26")}}>3.00PM</button>
                <button onClick={() => {handleButtonClicks("3.00PM"); handlesButtonClicks("2023-03-27")}}>3.00PM</button>
                <h3>Friday</h3>
                <h3>Saturday</h3>
                <h3>Sunday</h3>
                <h3>Monday</h3>
                <h3>Tuesday</h3>
                <h3>Wednesday</h3>
                <h3>Thurday</h3>
            </div>
        </div>

        <div className="box4">
            <h3>Summary</h3>
            <h1 className="listno4">4<span>/5</span></h1>
            <div>
                <h1 className="category4">Summary</h1>
                <h4 className="category44">Booking details below</h4>
            </div>

            <div className="icon">
                <div className="icon1">
                    <img className="iimg1" src="./Logoimg/calender.png" alt="Companycart"/>
                    <div className="dname1">
                    <h2>{clickedsButtons}</h2>
                    <h4>Appointment Date</h4>
                    </div>
                </div>
     
                <div className="icon2">
                    <img className="iimg2" src="./Logoimg/clock.png" alt="Companyclock"/>
                    <div className="dname2">
                    <h2>{clickedButtons}</h2>
                    <h4>Appointment Time</h4>
                    </div>
                        
                </div>
     
                <div className="icon3">
                    <img className="iimg3" src="./Logoimg/stopwatch.png" alt="Companystop"/>
                    <div className="dname3">
                    <h2>{clickedButton}</h2>
                    <h4>Service Category</h4>
                    </div> 
                </div>
     
                <div className="icon4">
                    <img className="iimg4" src="./Logoimg/cart.png" alt="Companycal"/>
                    <div className="dname4">
                    <h2>{total}</h2>
                    <h4>Total Cost</h4>
                    </div>        
                </div>
        </div>
            </div>

            <div className="box5">
                <h3>Summary</h3>
                <h1 className="listno5">5<span>/5</span></h1>
                <div>
                    <h1 className="category5">Basic Informations</h1>
                    <h4 className="category55">Fill out this fields below</h4>
                </div>

                <div className="inbox1">
                    <input placeholder="First Name *" type="text"/>
                    <input placeholder="Last Name *" type="text"/>
                    <input placeholder="Company Name *" type="text"/>
                </div>

                <div className="inbox2">
                    <input placeholder="Email Id *" type="text"/>
                    <input placeholder="Phone *" type="text"/>
                </div>

                <div className="inbox3">
                    <input placeholder="Address *" type="text"/>
                    <input placeholder="Message *" type="text"/>
                </div>
            </div>

            <div className="box6">
                <h4>We will confirm your appointment with you by phone or e-mail within 24 hours of receiving your request.</h4>
                <h4><input type="checkbox"/>I agree Terms and Conditions</h4>
                <select>
                    <option>Select Payment Type</option>
                    <option>Cash</option>
                    <option>Bank Transfer</option>

                </select>
                <button>Book Now</button>
            </div>
        </div>

        <div className="footer">
                <h4>© 2014 - 2023. <span className="footerspan">Washigniter</span> - All Right Reserved.</h4>
        </div>
        </>
    )
}
export {Application};