Questions tagged [react-class-based-component]
230 questions
0
votes
0 answers
Conditional render of super index with react
I'm having a hard time trying to achieve this approach:
I have to add a super index number only in some list items depending on their ID.
What I is when product with id 198940 and 20084 both exist will render 198940 with superIndex 1 and 20084 with…

danipereiracodes
- 25
- 4
0
votes
0 answers
How to add a serial number column in datatable, that shows serial number in ascending order even when table is sorted by column
I have created a DataTable in my React project. I am trying to include a serial number column and with my current approach it works as per my requirement for on page load results and pagination.
[ 1, 2, 3, 4, 5... ]
The issue is while trying to sort…

indiedev
- 21
- 3
0
votes
0 answers
How to calculate total revenue based on start date and end date selection
I have a react function am using to calcuate the total amount of revenue based on selected dates using react-datepicker. However, when i select the startdate and enddate am getting total of less one day. For instance if i select the period from 11th…

user20183888
- 37
- 1
- 6
0
votes
1 answer
How to update URL on page scroll without hooks in react?
I am trying to create a smooth scrolling page in React. The page is split into 4 sections:
Overview
About us
Courses
News
So on scrolling, if it's at the section 'News' with the id=news the URL should be updated to: website.com/specific-string#news…

Gareema
- 21
- 1
- 5
0
votes
0 answers
Using context state in class component, variable not defined error
I'm a little unfamiliar with class components in react.
I am trying to figure out how to pass down a prop via context. This state contains an array of 2 objects, representing 2 different users.
When this state is updated I would like to render…

Emm
- 2,367
- 3
- 24
- 50
0
votes
0 answers
How to set state initially based on different state in class component
I have a requirement where in I have to set the initial state value of the state based on the other state value in class based component.
this.state = {
element1: false,
element2: element1 ? "show": "hide"
}

Wasif
- 183
- 2
- 3
- 14
0
votes
1 answer
React - passing props into a Class component via a
I'm trying to pass props from one component into a Class component via a using React-Router.... But I'm having trouble...
I have this code in one component wrapping text/image:

Rob BB
- 1
- 1
0
votes
1 answer
How can I call an array from one component to show in another component using Class Component in React-js?
I have a question that I believe that is simple, buuut I couldn't solve it and I didn't find something similar on the internet.
I have a React Component that have an array like state and I'm trying to take this array and put in another array into a…

Jorge L
- 11
- 3
0
votes
1 answer
problem function is not being defined in react class based component
I created a state and assigned a function to change the state using setState() and passed the function to a component but the function is not declared.
News.js:34 Uncaught (in promise) TypeError: this.setProgress is not a function
at…

Pratik Chitte
- 1
- 1
0
votes
1 answer
How to use createRef to toggle Accordion list items
I have a FlatList and each item is an accordion, I m using class based react and I want to be able to toggle each accordion individually using createRef but I was unsuccessful
export default class shopingScreen extends React.component{
…

Rihab sabri
- 301
- 2
- 16
0
votes
2 answers
How to post an object in a react class component
Here is my CustomerBill.js
import React, { Component } from "react";
import "bootstrap/dist/css/bootstrap.min.css";
import axios from "axios";
import $ from "jquery";
import Box from "@mui/material/Box";
import…

user20183888
- 37
- 1
- 6
0
votes
0 answers
No Firebase App - using firebase in react application
I am new to react and I am trying to connect to firebase in a class component and I get an error
Uncaught FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app-compat/no-app)
how to fix…

BRDroid
- 3,920
- 8
- 65
- 143
0
votes
1 answer
How do i put entities into props after fetching it from componetDidMount?
inside componentDidMount Im calling the dispatched fetchReviews. but once mounted how does the fetched reviews get set in props?
business show component:
import React from "react";
import { Link } from 'react-router-dom';
import Star from…

vstoic
- 17
- 3
0
votes
0 answers
This function was used in class components, now I want to change that in functional component. How can I do that?
`
if (sInd === dInd) {
const reorderCardItems = reorderCard(items[sInd], source.index, destination.index);
const newState = [...items];
newState[sInd].card = reorderCardItems;
seState({newState: newState});
`
if (sInd…

Namana Khare
- 1
- 2
0
votes
3 answers
how do I convert my componentDidMount function to async componentDidMount type
This is my newsapp and this my News.js file of component folder
import React, { Component } from 'react'
import NeswItem from './NewsItem'
export class News extends Component {
constructor(){
super();
this.state={
data :…

ashish
- 3
- 5