Most voted "react" questions
It is an open source Javascript library for creating user interfaces. It is maintained by Facebook, Instagram and a community of individual developers and other companies
Learn more…1,420 questions
Sort by count of
-
0
votes2
answers113
viewsPrevent screen scrolling when opening modal in Reactjs
Hello, I am creating a site where one of the pages has a list of various clickable items (such as a ? shop window' of online stores), when clicked will open a modal that will be in front of all…
-
0
votes1
answer227
viewslocalstorage with React Redux
Good morning, I’m doing a test with React-Redux and localstorage .. it works normal however if I give F5 on the page it does not recover the data that was being saved in localstorage.. someone knows…
-
0
votes1
answer173
viewsuseEffect does not recognize new value
The useEffect hook fires when some variable in your array refreshes. However, when the value of the variable remains the same, the hook simply ignores. This hook gets a value and a push on the array…
-
0
votes1
answer88
viewsTypescript error after using React-bootstrap Navbar. How to resolve and use React-bootstrap import?
I am trying to use a Navbar component of React Bootstrap and when compiling the code the following error appears: Failed to compile.…
-
0
votes1
answer87
viewsHelp with Spread Operator in React
I have an array of objects saved in my state. const [rows, setRows] = useState(); Every time I click on a button it triggers this function function processRow(value) { setRows(row=>[ ...row,…
-
0
votes2
answers467
viewsShare a Hook from one component to another
My question is the following, I have a component in React called Navbar.jsx and would like the title no Navbar changed as soon as another component was opened. For example, when you open the…
-
0
votes1
answer855
viewsHow to use props in Styled-Components?
I would like to use props in a attr of a component in Styled-Components, that is to say: export const Button = styled.input.attrs({ type: 'button', value: `${props => props.value}` })` display:…
-
0
votes0
answers268
viewsDynamic tag typing in React with Typescript
What’s going on I have a button component with its dynamic html tag [a, button], but the way I called it shows error in some props like the onClick, anchor who receives an event of type click on…
-
0
votes1
answer197
viewsComponent is rendered again whenever some input state is changed
Good morning guys. I am developing an application where the user registration is according to the option that it selects " Physical or Legal ". According to the option that he chooses a form is…
-
0
votes0
answers66
viewsUsing query router with Nextjs
I’m creating a referral link to my site (someone will give this link to someone else, who will get a discount), when I use the link in environment on my machine, it usually works the router.query,…
-
0
votes1
answer419
viewsBad Request 400 - Using Fetch API
I’m having trouble accessing my api using POST method. This is my requisition: function createTool(token, obj) { return fetch(`${url}/tools`, { method: 'POST', headers: { Authorization: token, },…
-
0
votes0
answers52
viewsHow to correctly fill rows and columns using React datasheet?
I’m using the react datasheet to export and import data by pasting into my application tables. I expect all columns and rows I copy to be pasted normally. However, only one row and two columns are…
-
0
votes1
answer33
viewsHow to place the Icon at the end of an H4
I’m trying to make a button in React, but unfortunately I can’t put Icon behind the phrase import React from 'react'; export function BotaoMenu(){ return( <> <div className="row-flex-auto…
-
0
votes1
answer268
viewsProblems using React Context
I’ve been studying React and developing an app, but I have a problem when I try to use context. In one component, I create the context and provide its value, but when I try to use the current value…
-
0
votes1
answer797
viewsHow to get an answer that is in the request header
I’m making a site that contains a forum and I need to pick up the amount of topics and registered users and with this in my back-end I send these quantities by header. I’m using in my back-end Cors,…
-
0
votes2
answers73
viewsSend custom property to Privateroute component in React
Problem: Basic information: React project with the following dependencies.: "dependencies": { "@emotion/core": "^10.0.35", "@fortawesome/fontawesome-free": "^5.14.0",…
-
0
votes1
answer336
viewsHow to resolve Marker error using Leaflet + React-leaflet?
Following the guidelines of Leaflet’s documentation: https://leafletjs.com/examples/quick-start/ Similarly, following the React-leaflet guidelines for installation:…
-
0
votes0
answers68
viewsHeaders on GET request with SWR
Good morning guys. I would like to know how I can pass headers on a GET request with the SWR. My need lies where I need to show all the registered products of a company, where the ID of this is…
-
0
votes0
answers23
viewsForm field does not focus on not stating data or contain invalid information. React-Hooks-Forms w/ Imask
I have a form for entering data such as credit card, as can be seen below: React.useEffect(() => { register({ name: 'cardNumber' }, { required: true, validate: isValidCardNumber }) register({…
-
0
votes1
answer56
viewsFunction Result Displayed in Multiple Lines
I need to display the result of the sum of my items in one line only. I made a function to add the values of a list of objects, the result of the sum is given right but it needs to appear in only…
reactasked 4 years, 1 month ago user188554 -
0
votes1
answer92
viewsAdd values of two inputs within an array?
Could someone help me. Sane 4 inputs on the screen where the person enters with the notes. I am doing the following, I take the value of each input and play within an array to add up later. However…
-
0
votes1
answer138
viewsPlace the values of two inputs inside an array in React?
How do I take the values of two inputs and place inside an array with the event onChange? For example: input1 = 10; input2 = 20; notas = [10, 20]; Follows the code: import React, { Component } from…
-
0
votes0
answers225
viewsError while running project React-Native run-Ios
I have a project in Act-Native 0.62 The project is already in its final phase, including the android part is already working well, ready for release. Recently I got a Mac late 2009 borrowed, I…
-
0
votes1
answer56
viewsWhy do I receive "user" as indefined?
I am receiving user as Indefined but I don’t understand the reason. Can help me? import React from 'react'; class Main extends React.Component { state = { listaMensagens: [ { usuario: "", mensagem:…
-
0
votes2
answers429
viewsPassing parameter navigation from stack navigation to child component
I’m new to React On and I’m building an app where I need to rethink the same code several times with only a few differences, so I’m creating components for this, but in one of the components there…
-
0
votes1
answer187
views400 Bad request on express and typeorm server
Hello, I’m trying to create a user, but when sending the post method with the user data I get one 400 Bad Request server, the problem is that the server is not understanding the data, in the error…
-
0
votes2
answers1471
viewsHow to change color of a div with button click on Reactjs + CSS
I’m trying to change the color of div with button click, apparently it was supposed to work, but it only works on the second click, I don’t understand. The code is like this : The function I change…
-
0
votes0
answers259
viewsReact component rendering twice
Guys I’m having a problem where my components are rendered 2/3 times and I’m suspicious of an implementation, but I’m not sure if it’s her fault. The implementation is as follows, I have a…
-
0
votes1
answer450
viewsArray using useState React.Js Hooks
I’m having a problem with a project I’m using React.js, and axios for consumption of API const [id, setId] = useState(''); const [image, setImage] = useState(''); const [att, setAtt] = useState(0);…
-
0
votes0
answers59
viewsGet Access Token after login - React + Axios
I’m trying to globally set the token based on the login function response. Previously received in response the token information, but now, no more... Accessing the developer tools, Chrome Network…
-
0
votes0
answers191
viewsUsing React, Typescript and Nodejs. I need to login and logout users
Frontend import React from 'react'; import { Link } from 'react-router-dom'; import Header from '../../components/header/header' import './login.css' import loginImage from…
-
0
votes0
answers12
viewsError: Invalid element of type passed to PDF renderer
I would like to implement the PDF download in my project, however the File is not being downloaded, and the terminal returns this error " Error: invalid element of the type passed to the PDF…
-
0
votes1
answer63
viewsReact - React-router-dom repeating components
I am developing a login/registration page in React, however, I came across the following problem: <div className="auth-container"> <BrowserRouter> <Hint /> <Switch> <Route…
-
0
votes1
answer47
viewspdfmake__WEBPACK_IMPORTED_MODULE_16___default Reactjs error
When I start my project this returns the following error: TypeError: pdfmake__WEBPACK_IMPORTED_MODULE_16___default.a is not a constructor Follows information: Import: import _ from 'lodash'; import…
-
0
votes1
answer199
viewsJest gives error: "Typeerror: expect(...). toHaveStyle is not a Function"
I’m trying to use jest to test the style of a component, and it’s giving me this error: "TypeError: expect(...).toHaveStyle is not a function" It is a simple component I created only with…
-
0
votes1
answer213
viewsHow to increase bar thickness in Chart.js?
I am using Chart.js in React and would like the bars on my chart to be thicker without piling up. Next is my component rendering the graph: import React from 'react'; import { HorizontalBar } from…
-
0
votes1
answer175
viewsImage gallery in React, how to select the active image and reflect only on the component itself?
Save guys! No bullshit, follow the gif to get a sense of the problem: My list of items is being pulled from a JSON, where in the listing of all my items I made a map(). const [imageSrc, setImageSrc]…
-
0
votes1
answer150
viewsButton to close modal does not work
Hello, I’m having a problem to make my modal button close, it opens through the header of the normal application. I am using Reactjs 16.8 + Typescript 4.0.3. // Header/index.tsx import ContactForm…
-
0
votes0
answers32
viewsError 401 when performing post request for an API itself
Hello, I am trying to make a post request for an API of my own in order to simulate a "like", the problem is that it is always returned the error 401 whenever I post request, however if I perform a…
-
0
votes0
answers30
viewsProperty condition in CSS class
I use a private library component in my project. This component is image upload and I need to remove the event from a button using the CSS but it is not possible to modify this button by code. Then…
-
0
votes0
answers54
viewsProblem deleting password from Authentication Routes
I’m having the following error The operand of a 'delete' Operator must be optional. when trying to delete the user password in the authentication routes, so that it does not go to the frontend. But…
-
0
votes1
answer42
viewsThe setState is not working
I’ve seen several posts about it, but none even agr helped me much... When it gives the console.log(this.state.list); the resulate is undefined... and I’m sure the data is coming from the API. Can…
-
0
votes1
answer71
viewsReact-Hooks/exhaustive-deps | Error in an assync function when taking data from an API
Hello, I’m having an error in React.Js that I don’t understand in trying to consume data from an API I created myself. I created a loop so that I could get the json information and print my site.…
-
0
votes1
answer31
viewsConditional rederization of a component from a selected item
good afternoon, I am going through difficulties to perform a conditional rendering that aims to render an Iconbutton only when and selected a value from the predefined list. my const with the list…
-
0
votes1
answer137
viewsDynamically change field in Reactjs
I am developing a project, and when typing a value in a field I need the other field to be changed based on the values I set in a function, here is the code: constructor(props) { super(props);…
-
0
votes1
answer42
viewsReact - Form taken from PHP giving error "CANNOT POST"
Hello, I’m having a problem reusing a form that I used to use in my html application so that I sent the data to a PHP file to insert into my MYSQL database. Unfortunately I am not able to take…
-
0
votes0
answers63
viewsButton does not call onsubmit in formik - React Native
all good? I have a Validator with Yup, and a formik, but somehow onsubmit is not called, when I click the button, I already checked in the Debugger if something is called and nothing :( This is my…
-
0
votes0
answers58
viewsCondition problems (if/Else) using React.js
My expectation: create a button that opens a modal for the user to enter information and this information turns a card to be shown on screen. The problem: I made an example in Codesandbox that…
-
0
votes0
answers191
viewsHooks: Usestate with dynamic array manipulation in React Native
Good morning/afternoon/evening, I need your help if possible... I own a hook const [itens, setItens] = React.useState([ { id: 1, nome: "Item 1" }, { id: 2, nome: "Item 2" } ]); In fact it is blank,…
-
0
votes0
answers24
viewsHow do I apply the style of a component to the Facebook Login button of the React-facebook-login?
I’m using the package react-facebook-login to create a Facebook login on a page. It already had a stylized button (component). However when I use the Login button component of the package, it is…