& gets replaced with & in react

I have the following code for my DOM. I need to render an iframe inside the DOM with a dynamic URL source. The problem is the URL contains parameters as such
http:/url?Id=122&category=sales&section=marketing&name=john

When the dom renders the iframe loads the URL and when inspecting the source of the iframe the & gets replaced with & amp ;

http://url?Id=122& amp ;category=sales& amp ;section=marketing& amp ;name=john

This obviously breaks the intended URL. How do I avoid this?

DOM Code

return (
                <div class="billing-enrollment-step">
                    <div class="final__register-wrapper">
                        <div class="final__register-block">
                            <h3 class="final__register-title">You're almost done!</h3>
                            <p>Enter your payment information and finalize your purchase. When finished click done.</p>
                            <table align="center">
                                <tr>
                                    <td>
                                        <div dangerouslySetInnerHTML={this.getBPUrl()} />
                                    </td>
                                </tr>
                                <td>
                                    <div class="spacer-tall" />
                                </td>
                                <tr>
                                    <td>
                                        <input type="submit" value="Continue" onClick={this.goToNextStep.bind(this)} />
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            );

JavaScript Code

getBPUrl() {
    return { __html: '<iframe src="'+this.ccUrl+'" width="1000" height="800" frameBorder="0">Browser not compatible.</iframe>' };
}

How to return property of all elements of array inside MongoDB document?

I want to return the title and _id properties of each element in my trips array of a user’s document. I am attempting to use the aggregate pipeline but its my first time and the docs are overwhelming. It seems like all the examples show how to find a single piece of data. I basically want to return something like


[
  {title: "one", _id: 123},
  {title: "two", _id: 456},
  {title: "three", _id: 789},
]

from my document that looks like:

enter image description here

Thank you in advance for any suggestions.

Win32 WebView2 Will Not Focus HTML Page

I am having a very difficult time trying to focus the HTML window that WebView2 loads on startup. I’ve tried JS focusing from within the web document, Callbacking back and forth between the C++ interface and the HTML page – nothing seems to work. The window will only be focused when some ‘action’ occurs like an alert dialog popping up. I was hoping to leverage the power of C++ and integrate it into the lightweight native browser client, but right now it is proving to be rather difficult. Would really appreciate some insight as to why this is occuring. I have shared 2 pieces of code, one is that of the WebView2 implementation, and the other one is a sample html file that focuses in normal situations.
Please do not forget to HTML path to your custom one, I have marked it out for your convenience.

  • Apologizing in advance for huge chunks of code, I am unaware if we are able to fold code here. Microsoft uses 12 lines to write one function prototype. Quite disorienting sometimes.

  • In case you do not use Visual Studio, I have made a script so that we are still able to compile and test the code (Run as .bat file):

@echo off
cl /EHsc /GR /FI"iso646.h" /Zc:strictStrings /we4627 /we4927 /wd4351 /W4 /D"_CRT_SECURE_NO_WARNINGS" /nologo /D_UNICODE /DUNICODE /DWIN32 /D_WINDOWS /c /Ipathtowebview2include /Ipathtowinrtinclude webweb.cpp&^
link webweb.obj WebView2Loader.dll.lib /subsystem:windows user32.lib&^
webweb.exe
pause
  • Sample WebView2 code for testing.
#include <windows.h>
#include <stdlib.h>
#include <string>
#include <tchar.h>
#include <wrl.h>
#include <wil/com.h>
// include WebView2 header
#include "WebView2.h"

using namespace Microsoft::WRL;

// Global variables

// The main window class name.
static TCHAR szWindowClass[] = _T("DesktopApp");

// The string that appears in the application's title bar.
static TCHAR szTitle[] = _T("WebView sample");

HINSTANCE hInst;

// Forward declarations of functions included in this code module:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

// Pointer to WebViewController
static wil::com_ptr<ICoreWebView2Controller> webviewController;

// Pointer to WebView window
static wil::com_ptr<ICoreWebView2> webviewWindow;

int CALLBACK WinMain(
    _In_ HINSTANCE hInstance,
    _In_ HINSTANCE hPrevInstance,
    _In_ LPSTR     lpCmdLine,
    _In_ int       nCmdShow
)
{
    WNDCLASSEX wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc = WndProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = hInstance;
    wcex.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
    wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    wcex.lpszMenuName = NULL;
    wcex.lpszClassName = szWindowClass;
    wcex.hIconSm = LoadIcon(wcex.hInstance, IDI_APPLICATION);

    if (!RegisterClassEx(&wcex))
    {
        MessageBox(NULL,
            _T("Call to RegisterClassEx failed!"),
            _T("Windows Desktop Guided Tour"),
            NULL);

        return 1;
    }

    // Store instance handle in our global variable
    hInst = hInstance;

    int dispw = GetSystemMetrics(SM_CXSCREEN);
    int disph = GetSystemMetrics(SM_CYSCREEN);
    int windw = dispw / 2;
    int windh = disph / 2;
    int x = (dispw - windw) / 2;
    int y = (disph - windh) / 2;

    // The parameters to CreateWindow explained:
    // szWindowClass: the name of the application
    // szTitle: the text that appears in the title bar
    // WS_OVERLAPPEDWINDOW: the type of window to create
    // CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
    // 500, 100: initial size (width, length)
    // NULL: the parent of this window
    // NULL: this application does not have a menu bar
    // hInstance: the first parameter from WinMain
    // NULL: not used in this application
    HWND hWnd = CreateWindow(
        szWindowClass,
        szTitle,
        WS_OVERLAPPEDWINDOW,
        x, y,
        windw, windh,
        NULL,
        NULL,
        hInstance,
        NULL
    );

    if (!hWnd)
    {
        MessageBox(NULL,
            _T("Call to CreateWindow failed!"),
            _T("Windows Desktop Guided Tour"),
            NULL);

        return 1;
    }

    // The parameters to ShowWindow explained:
    // hWnd: the value returned from CreateWindow
    // nCmdShow: the fourth parameter from WinMain
    ShowWindow(hWnd,
        nCmdShow);
    UpdateWindow(hWnd);

    // <-- WebView2 sample code starts here -->
    // Step 3 - Create a single WebView within the parent window
    // Locate the browser and set up the environment for WebView
    CreateCoreWebView2EnvironmentWithOptions(nullptr, nullptr, nullptr,
        Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
            [hWnd](HRESULT result, ICoreWebView2Environment* env) -> HRESULT {

                // Create a CoreWebView2Controller and get the associated CoreWebView2 whose parent is the main window hWnd
                env->CreateCoreWebView2Controller(hWnd, Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
                    [hWnd](HRESULT result, ICoreWebView2Controller* controller) -> HRESULT {
                        if (controller != nullptr) {
                            webviewController = controller;
                            webviewController->get_CoreWebView2(&webviewWindow);
                        }
                        // Add a few settings for the webview
                        // The demo step is redundant since the values are the default settings
                        ICoreWebView2Settings* Settings;
                        webviewWindow->get_Settings(&Settings);
                        Settings->put_IsScriptEnabled(TRUE);
                        Settings->put_AreDefaultScriptDialogsEnabled(FALSE);
                        Settings->put_IsWebMessageEnabled(FALSE);
                        RECT bounds;
                        GetClientRect(hWnd, &bounds);
                        webviewController->put_Bounds(bounds);
                        webviewWindow->AddScriptToExecuteOnDocumentCreated(L"text.setValue('ayee');", NULL);

                        
                        
webviewWindow->Navigate(L"file:///path/to/test.html");  



                        return S_OK;
                    }).Get());
                return S_OK;
            }).Get());
            


    
    // <-- WebView2 sample code ends here -->

    // Main message loop:
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return (int)msg.wParam;
}

//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_DESTROY  - post a quit message and return
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    TCHAR greeting[] = _T("Hello, Windows desktop!");

    switch (message)
    {
    case WM_SIZE:
        if (webviewController != nullptr) {
            RECT bounds;
            GetClientRect(hWnd, &bounds);
            webviewController->put_Bounds(bounds);
        };
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
        break;
    }

    return 0;
}
  • Sample HTML file for testing
<!DOCTYPE HTML>
<HTML>
<HEAD>
<STYLE>
body
{
    display: flex;
    width: 100vw;
    overflow: none;
    scrollbar: none;
    align-items: center;
    justify-content: center;
}
#textarea
{
    width: 400px;
    height: 400px;
    resize: none;
    overflow:auto;
}
</STYLE>
<TITLE>EXAMPLE</TITLE>
</HEAD>
<BODY>
<textarea ID="textpane"></textarea>
<SCRIPT>
var te = document.getElementById('textpane');
window.onload = function()
{
    te.focus();
}
</SCRIPT>
</BODY>
</HTML>

Java program execute issue with Geany

Every time I run/execute a java program with Geany, the issue comes out: program exited with code: 127, even though I am running the one that has been successfully compiled and executed before. Does anyone know how to fix this issue? Thanks a lot!

my data renders twice and returns empty on the first

For a project, I am getting multiple objects that all contain specific football match details, so I filter the matches by matchday but I keep getting an empty array on my first render, and then when I leave the tab and come back it then renders the objects I need, how do I get it to render once with my data

Here is my code:

//my states
     const [selectedLeague,setSelectedLeague]=useState({})
        const [loading,setLoading]= useState(false)
        const [competitions,setCompetitions]= useState([])
        const [matchday,setMatchDay]=useState([])
        const [matches,setMatches]=useState([])
        const [LeagueName,setSelectedLeagueName]=useState([])
        const area_ids= [2072,2114,2163,2077,2081,2088,2187,2224]

image of my states

so then I’m trying to get matches and filter by matchday

const getMatches= async()=>{
  const response = await axios.get(`${FOOTBALL_API_URL}/${selectedLeague}/matches`,{
        method: 'get', 
          headers: { 'X-Auth-Token': `${FOOTBALL_API_TOKEN}`}
  } );
    console.log('checking getmatch response',response)
   const data = await response.data
   console.log('checking response.data',data)

    setLoading(true)
    // set matchday
    setMatchDay(data.matches[0].season.currentMatchday)
    // filter matches by matchday
    const filter = data.matches.filter((match)=>{
     return matchday === match.matchday
  })
    // log the filtered array
    console.log('filtered array',filter)
   
   
  setMatches(filter)
 
 }

but I only get the matchday and When filtered list is first rendered it is always an empty list

filtered array []length: 0[[Prototype]]: Array(0)

console log showing empty array on the first render

I’ve tried tweaking my use effect but it only loops infinitely

React.useEffect(() => {
    getMatches()
}, [matches])

but when I leave the page and come back it then gets the data I need

filtered array 
(10) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0: {area: {…}, competition: {…}, season: {…}, id: 416384, utcDate: '2022-08-05T19:00:00Z', …}
1: {area: {…}, competition: {…}, season: {…}, id: 416383, utcDate: '2022-08-06T11:30:00Z', …}
2: {area: {…}, competition: {…}, season: {…}, id: 416378, utcDate: '2022-08-06T14:00:00Z', …}
3: {area: {…}, competition: {…}, season: {…}, id: 416379, utcDate: '2022-08-06T14:00:00Z', …}
4: {area: {…}, competition: {…}, season: {…}, id: 416381, utcDate: '2022-08-06T14:00:00Z', …}
5: {area: {…}, competition: {…}, season: {…}, id: 416382, utcDate: '2022-08-06T14:00:00Z', …}
6: {area: {…}, competition: {…}, season: {…}, id: 416377, utcDate: '2022-08-06T16:30:00Z', …}
7: {area: {…}, competition: {…}, season: {…}, id: 416376, utcDate: '2022-08-07T13:00:00Z', …}
8: {area: {…}, competition: {…}, season: {…}, id: 416380, utcDate: '2022-08-07T13:00:00Z', …}
9: {area: {…}, competition: {…}, season: {…}, id: 416375, utcDate: '2022-08-07T15:30:00Z', …}
length: 10
[[Prototype]]: Array(0)

console log showing filtered array with requested data

I need to get my data on the first render, I am new to hooks, so I’m hoping I’m missing something simple. Thanks.
please if you have any questions please reply to this trend.

In C programming When i say 6||b++ ( where int b =5) then why the value of b not changes to 6 [duplicate]

In my question, I am following the precedence order in order to solve the question.
Means the b++ part should be solved first as it is a post increment .
But when ,I print b after this, I get the answer of it as 5 or (b=5) in the output ???
please help me …..

#include<stdio.h>
int main(int argc, char const *argv[])
{
int b=5;


int x = 7||b++;
    printf("%d",b);
    return 0;
}

jQuery Circle Progress prevent the animation start from 0 if data updated

I’m using jquery-circle-progress plugin.

The code is working perfectly. But now I put 1 button there to update the value of percentage.

<button id="add">Add</button>

As you can see below example, When I click the button then the circle progress will update the data but I want the animation is not reset from 0, just continue from current value to updated value.

Is it possible?

let options = {
        startAngle: -1.55,
        size: 150,
        value: 0.85,
        fill: {gradient: ['#a445b2', '#fa4299']}
      }
      $(".circle .bar").circleProgress(options).on('circle-animation-progress',
      function(event, progress, stepValue){
        $(this).parent().find("span").text(String(stepValue.toFixed(2).substr(2)) + "%");
});

$(".react .bar").circleProgress({
  value: 0.60
});

$('#add').on('click', function(){
  $(".react .bar").circleProgress({
  value: 0.80
  });
});
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap');
*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}
body{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: -webkit-linear-gradient(left, #53c68a, #8b67c4);
}
.wrapper{
  width: 1000px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}
.wrapper .card{
  background: #fff;
     width: calc(25% - 8px);
  height: 300px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  flex-direction: column;
  box-shadow: 0px 10px 15px rgba(0,0,0,0.1);
}
.wrapper .card .circle{
  position: relative;
  height: 150px;
  width: 150px;
  border-radius: 50%;
  cursor: default;
}
.card .circle .box,
.card .circle .box span{
  position: absolute;
  top: 50%;
  left: 50%;
}
.card .circle .box{
  height: 100%;
  width: 100%;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  transition: all 0.2s;
}
.card .circle:hover .box{
  transform: translate(-50%, -50%) scale(0.91);
}
.card .circle .box span,
.wrapper .card .text{
  background: -webkit-linear-gradient(left, #a445b2, #fa4299);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.circle .box span{
  font-size: 38px;
  font-family: sans-serif;
  font-weight: 600;
  transform: translate(-45%, -45%);
  transition: all 0.1s;
}
.card .circle:hover .box span{
  transform: translate(-45%, -45%) scale(1.09);
}
.card .text{
  font-size: 20px;
  font-weight: 600;
}
@media(max-width: 753px){
  .wrapper{
    max-width: 700px;
  }
  .wrapper .card{
    width: calc(50% - 20px);
    margin-bottom: 20px;
  }
}
@media(max-width: 505px){
  .wrapper{
    max-width: 500px;
  }
  .wrapper .card{
    width: 100%;
  }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-circle-progress/1.2.2/circle-progress.min.js"></script>
<div class="wrapper">
  <div class="card react">
    <div class="circle">
      <div class="bar"></div>
      <div class="box"><span></span></div>
    </div>
    <div class="text">React JS</div>
  </div>
</div>

<button id="add">Add</button>

How to proceed only when the audio is done playing in javascript?

I have the following javascript code

var audio = new Audio('{{ path }}');

function play() {
  audio.play();
}

statusElement = document.getElementById("audio-status")
statusElement.innerHTML = "Playing the audio"
play()
statusElement.innerHTML = "done playing the audio"

Now, when I run this code, I see that the statusElement displays “done playing the audio” while the audio is still playing.

I think that this might be because the audio.play() function runs asynchronously, however, that’s not what I want.

I want to first display, “Playing the audio”, and then wait for the audio to play, and after that display “done playing the audio”. How should I go about doing this?

Is using an if statement to redirect user away if page does not exists good practice in React?

Basically, I am trying to route a user based on whether or not the page exists. So I tried to do an if statement to check the prop profileExists. If it is true, it would stay on the same page. Otherwise, it would reroute the user away to another route, which is the /homepage route. I was wondering if this is an ok thing to do in React or not. Please see code below:

renderWithRoot(component) {
  const { classes, profileExists, history } = this.props;

  if (profileExists === false) {
    history.push('/homepage');
  }

  return (
    <div className={classes.root}>
      {component}
    </div>
  );
}

React Spring Leave Animation

For some reason the menu leave transition isn’t working and I can’t figure out why. I want the menu to move in from far bottom and then once isMenuOpen === false have menu exit back downwards.Hopefully someone is able to enlighten me xD

I deleted a bunch of stuff from App.jsx for the sake of easier reading, so no one has to riffle through a ton of code.

App > Header > Nav

App.jsx

import React, { useState } from 'react';
import { useTransition } from 'react-spring';
import './scss/app-styles.css';
import { Outlet } from 'react-router-dom';
import Login from './view/Login';
import SignUp from './view/SignUp';
import Header from './view/Header';
import Footer from './view/Footer';

const App = () => {
  const [isMenuOpen, setIsMenuOpen] = useState(false);
  // TEMP VALUE
  const [user] = useState(true);

  const animMenu = useTransition(isMenuOpen, {
    from: { opacity: 0, transform: 'translate3d(0, 1000%, 0)' },
    enter: { opacity: 1, transform: 'translate3d(0, 0, 0)' },
    leave: { opacity: 0, transform: 'translate3d(-100%, 0, 0)' },
  });

  return (
    <div className="App">
        <>
          <Header anim={animMenu} isMenuOpen={isMenuOpen} setIsMenuOpen={setIsMenuOpen}/>
          <Outlet />
          <Footer />
        </>
    </div>
  );
};

export default App;

Header.jsx

import React from 'react';
import './scss/header-styles.css';
import * as HiIcons from 'react-icons/hi';
import Nav from '../NavHam';

function Header({ anim, isMenuOpen, setIsMenuOpen }) {
  const handleToggle = () => {
    setIsMenuOpen(!isMenuOpen);
  };

  return (
    <header>
      <div className="nav-ham" onClick={handleToggle}>
        <HiIcons.HiMenu />
      </div>
      {anim((style, item) => {
        if (item) {
          return (
            <Nav toggle={handleToggle} isOpen={isMenuOpen} style={style} />
          );
        }
      })}
    </header>
  );
}

export default Header;

Nav.jsx

import React from 'react';
import { animated } from 'react-spring';
import './scss/nav-styles.css';

const Nav = ({ isOpen, style }) => {
  return (
    <>
      {isOpen ? (
        <animated.div className="menu" style={style}>
          <div>
            <a href="/">Home</a>
          </div>
          <div>
            <a href="/">About</a>
          </div>
          <div>
            <a href="/">Contact</a>
          </div>
          <div>
            <a href="/">Login</a>
          </div>
          <div>
            <a href="/">Sign Up</a>
          </div>
        </animated.div>
      ) : (
        ''
      )}
    </>
  );
};

export default Nav;

Is it possible to store what the user selects from a dropdown menu into an array in javascript? [duplicate]

So I have this piece of code for my html that displays a dropdown menu and I was wondering if it is possible to store what the user chooses (i.e 2000 – 2009 and Good Movie) into an array?

<form action="">
  <label for="movieYear">Choose A Year</label>
  <select id="movieYear" name="movieYear">
    <option value="primary_release_date.gte=2009-12-31&primary_release_date.lte=2022-07-14">
      2010 - 2022
    </option>
    <option value="primary_release_date.gte=1999-12-31&primary_release_date.lte=2010-01-01">
      2000 - 2009
    </option>
    <option value="primary_release_date.gte=1989-12-31&primary_release_date.lte=2000-12-31">
      1990 - 1999
    </option>
  </select>

  <label for="movieScore">Choose A IMDb Score</label>
  <select id="movieScore" name="movieScore">
    <option value="desc">Good Movie</option>
    <option value="asc">Bad Movie</option>
  </select>
  <input type="submit" value="Submit" class="submitButton" />
</form>

How to send a Whatsapp message to a phone # without having to press SEND button?

I have seen many people asking this and would like to know if now (july 2022) is possible?
I need to send a message to a WhatsApp group but could not. If not possible, to send to a list of whatsapp numbers but having to press SEND button each time is frustrating.
Would it be possible to send the message to some WhatsApp Business # and from there send the message to a list, all automatic?
Any ideas?

React Redux not displaying the data when trying to dispatch (Firestore)

I’m trying to use React Redux on my application. I will be building something like instagram, so the scale of the application is going to be big. I have implement redux correctly (I believe) although I’m not getting the fetch result from firestore on the dispatch function, if I insert the same code before the return it works.
action/index.ts:

import { db, auth } from '../../services/firebase';
import { USER_STATE_CHANGE } from '../constants';

export function fetchUser() {
  return (dispatch: any) => {
    db.collection('users')
      .doc(auth.currentUser!.uid)
      .get()
      .then((snapshot) => {
        if (snapshot.exists) {
console.log(snapshot)
          dispatch({
            type: USER_STATE_CHANGE,
            payload: snapshot.data(),
          });
        }
      });
  };
}

constants/index.ts:

export const USER_STATE_CHANGE = 'USER_STATE_CHANGE';

reducers/index.ts:

import { combineReducers } from 'redux';
import { user } from './user';

const Reducers = combineReducers({
  userState: user,
});

export default Reducers;

reducers/user.ts:

const initialState = {
  currentUser: null,
};

export const user = (state = initialState, action: any) => {
  return {
    ...state,
    currentUser: action.currentUser,
  };
};

App.tsx:

// Redux
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import rootReducer from './src/redux/reducers';
import thunk from 'redux-thunk';

const store = createStore(rootReducer, applyMiddleware(thunk));

export default function App() {
  if (!fontsLoaded) return <></>;

  return (
    <ThemeProvider theme={theme}>
      <Provider store={store}>
        <Main />
      </Provider>
      <ToastMessage />
    </ThemeProvider>
  );
}

Main.tsx:

import React, { useEffect, useState } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { StatusBar } from 'expo-status-bar';
import { AuthRoutes } from './routes/auth.routes';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { fetchUser } from './redux/actions';
import { auth } from './services/firebase';

function Main() {
  const [isAuthenticated, setIsAuthenticated] = useState(false);

  useEffect(() => {
    fetchUser();

    auth.onAuthStateChanged((user) => {
      if (user) setIsAuthenticated(true);
    });
  }, []);

  return (
    <NavigationContainer>
      <AuthRoutes isAuthenticated={isAuthenticated} setIsAuthenticated={setIsAuthenticated} />
      <StatusBar style="auto" />
    </NavigationContainer>
  );
}

const mapDispatchProps = (dispatch: any) => bindActionCreators({ fetchUser }, dispatch);

export default connect(null, mapDispatchProps)(Main);

The fetchUser() is called here, and should log the data from firestore, although I don’t get any data logged.

The function is beeing called:
enter image description here

Factorial and string value [duplicate]

I have to create a program that gives me the number of combinations I could make with the letters in a word for example I type “four” it has 4 letters the factorial or number of combinations is 24. I wrote this code but it gives me 1 as answer not matter what I type.

<title> Number of ways the letters that make up the word can be arranged</title>

<script type="text/javascript">
  function calculate() {
    var theWord = document.getElementById('theWord').value;
    var factorial = 1;
    for (var i = 1; i <= theWord; i++) {
      factorial *= i;
    }
    document.getElementById('results').innerHTML = factorial;

  }

</script>
<h1> Number of ways to arrange a word calculator</h1>
<p>
  Type a word <input id='theWord'><button onClick='calculate()'>
    Calculate
  </button>
</p>
<p id='results'>
</p>