Questions tagged [react-class-based-component]

230 questions
0
votes
1 answer

React nested state object not updating

I am trying to update a nested state object (checkedObjects) in a react class component, to track when checkboxes are checked and unchecked. checkedObjects has the following structure: checkedObjects: { [assignmentName]: boolean, } verifyObjects…
tlockhart
  • 381
  • 2
  • 7
0
votes
1 answer

how to close hamburger menu in react class based component

I am working on react classs based component I have hamburger[https://easyupload.io/isutmy] whenever I am clicking on closing the hamburger so it is working properly but what i need is whenever i click outside the on webpage so it should close…
0
votes
1 answer

Does LayoutAnimation work with functional component

I'm developing a react native app with the use of class component mostly. Class component gives me the ability to animate with only 4 lines of code: componentWillUpdate() { UIManager.setLayoutAnimationEnabledExperimental &&…
0
votes
1 answer

How to use react router in v6 class components with id as parameter

I have a Component Tutorials where I have to display description on the basis of ID and there I am embedding other component TutorialsSidebar which will display list of Tutorials. In TutorialsSidebar I have a link so when I click on that I want to…
user15842079
0
votes
0 answers

Class based component. Warning: Functions are not valid as a React child. This may happen if you return a Component instead of

So, I'm doing some assignment and I get the following error when running my react app (Should be a dynamic URL like /item/n): Warning: Functions are not valid as a React child. This may happen if you return a Component instead of from…
0
votes
1 answer

Adding properties on this vs adding properties on this.state. What's the difference?

I know functional components are easier to use than class components but I'm trying to learn doing things using both of them to understand better. So I looked up some examples at official react website. The Timer example at…
Omkar76
  • 1,317
  • 1
  • 8
  • 22
0
votes
1 answer

How to rerender class component in react js

How do I Re render the class component once API call is done. Initially the state is set as null. before I could get the data from API the default null value appears in the page. whereas It is possible in functional component with hooks. likewise…
Gowtham
  • 21
  • 4
0
votes
0 answers

React Router v6 Button onclick Navigate vis class components

Trying to port an application from router v2 to router v6. Everything I see everywhere is hooks. Tried to make a custom withRouter, "Hooks can only be called inside of the body of a function component." The button in question
0
votes
0 answers

Unhandled Runtime Error in react class component when using async function

When I run getData in the following const FunctionalComponent = observer(): JSX.Element => { const { userStore, authStore } = useStores() const getData = async (): Promise => { const result = await userStore.findById(authStore.id) …
dev_el
  • 2,357
  • 5
  • 24
  • 55
0
votes
1 answer

How to replace existing object in array only modifying its props and not affect to other items?

I'm trying to add item to the cart. If it is in cart, I want to replace this item with updated count and total accordingly, but I don't want to affect to other items. If it is not in cart I add it (logic of if statement). How to implement logic of…
0
votes
1 answer

Typing a class component with no props

I am trying to type a class component with no props import React, { Component } from "react"; type Props = {}; class MyComponent extends Component { constructor(props: Props) { super(props); this.state = { hasError: false }; } …
TommyD
  • 913
  • 3
  • 17
  • 32
0
votes
2 answers

React Map is not reading properties

I am learning react. It is showing an error. I tried many time to solve it but failed. I tried changing this.state.article with this.article but in vein- I even tried to cover this in function but it didn't work. constructor(){ super(); …
0
votes
1 answer

How to iterate and display each element from inner list - reactjs

How to iterate and display each element from 'grandChildren' list -> for eg: ["AQ11", "AS12"]. Thank you. responseData: [{Key:"A",Value:["AQ11", "AS12"]}, {Key:"C",Value:["CN22", "CL33", "CV44"]}]. Have set KeyValuePair's key to 'children' and…
Sarahrb
  • 407
  • 11
  • 24
0
votes
1 answer

How to access all elements from dictionary - ReactJS

API returns parents and their children in a dictionary. // Dictionary with string as its key(parent) and list of strings(children) as its value as below: { "A": ["AQ11"], "B": [], "C": ["CN22", "CL33"] } I have two questions, Have I set my…
Sarahrb
  • 407
  • 11
  • 24
0
votes
1 answer

'this' inside a function of a class component (react)

I am converting class components into functional components and get the error during removing 'this'. The original project (with class components) runs well. But when I remove 'this' from 'this.intervalID', it shows an error It confuses me, because…