Category "reactjs"

Get Authenticated user in a React JS app which is behind Google IAP

I have a React JS app which is behind the Google IAP. I need to get the IAP authenticated user email and use it in the app. How can I do that? IAP adds X-Goog-A

Cannot read properties of undefined (reading 'bind') useQuery

I have this code right here import React from "react"; import { useQuery } from "@apollo/react-hooks"; import gql from "graphql-tag"; const FETCH_POSTS_QUERY

How to import SVG into Next.js component?

I am trying to import an SVG image from file into a Next.js component. In the assets folder I have google.svg (icon): <svg className="svgIcon-use" width="25"

React-leaflet map shows scattered blocks of maps

I was trying to show a sample map on my react website. I have installed the leaflet package and also the react-leaflet package then set everything up as the rea

How to make Visual Studio Code show errors when using missing SCSS styles in a React app?

In my React app I import styles from a SCSS file like this: import styles from './index.module.scss'; To use a particular SCSS style I set up a className on a

How can I write a jest test if in a component uses a function that is passed through the context?

It is necessary to test the component SlotItem. In it function is transferred through a context this.context.i18n.t("free") My component: import React from 'r

Does useCallback make sense for not memoized components?

During reconciliation react compares trees and gets differences. Does it make sense to decrease those differences by using memoization hooks when components are

How can I solve react dom warning message?

How to solve this warning message? react-dom.development.js:86 Warning: Cannot update a component (BrowserRouter) while rendering a different component (SocialL

How to plot x,y coordinates of item on a image in html

I need to place/plot a pin(Small image to point the parts of person) on a image(For example: A image of person). I am getting x,y,height,width values from ser

How to show a dropdown list on a contentEditable span/div item when user tries to change the text of span

I have a contentEditable span element defined as: <span contentEditable={this.props.enableEditColumn} onKeyPress={this.checkInput.bind(this,columnDef)}>

Trigger onblur event on click of enter keypress in React js

I have an input text field . When a user inputs any text and clicks enter button I need to activate the blur event to remove the focus and also to validate the

React router, redux, electron: router isn't rendering

I'm trying to get react-router to work in an electron app. I'm using a boilerplate and stripped away some of the stuff I don't want but that should provide a pr

Secure Node API for React Front End

I’m building a React application with a Node backend. In the backend I have an API that just talks to a database and I can deploy the API and the React ap

Unable to save to array React state from the response from the server

I'm trying to save my response.data to my array state of React, but it never stores the correct array. But when I do a temporary array it works. const [allstude

Apollo `useMutation()` stuck loading inside Next.js component

The following form component in Next.js submits without errors but never completes the mutation. Instead it get's stuck in the loading state. import React, { us

How can I increase and decrease the quantity in reactjs?

I have a button and an input form. When clicking the button, my product quantity decreases by 1 and increases quantity when submitting the form. Quantity increa

TailwindCSS 3 classes doesn't override previous classes

I am facing an issue which is mind-numbing in the world of CSS. TailwindCSS 3 classes just doesn't override previous classes. For example, there is this compone

I18next and Webpack

I'm starting with Webpack and find problem with react i18next hook-useTranslation. // webpack.config.js const path = require('path') const HtmlWebpackPlugin = r

dangerouslySetInnerHtml doesn't update during render

So I made a component for including content-editable components in my app. I copied it from some gist I believe, then edited to what i needed. The code is belo

How to test a required input field with React Testing Library and Jest?

I tried to test a required input field with React Testing Library and Jest by testing the existence of the popover, but I failed. I tried several variants and n