Questions tagged [react-class-based-component]
230 questions
1
vote
1 answer
How can we stop repeated calls in componentDidUpdate() lifecycle of a class based component, like we do in useEffect hook?
useEffect(()=>{
fetch(`${BASE_URL}/requested_url`)
.then(response => response.json())
.then(json => setData(json))
}, []);
When I used a class based component, I had to use a state boolean to specify when…

Yash Datir
- 11
- 3
1
vote
1 answer
Moving external library from Class-based to Functional Component in React
I'm using the JExcel javascript library with React. The documentation outlines the approach with Components, but makes use of ReactDOM.findDOMNode() which I believe has been deprecated.
I've tried moving it to a functional component, but whilst it…

Dycey
- 4,767
- 5
- 47
- 86
0
votes
1 answer
How to customize Excel sheet format after download in HighCharts
I am trying to download my excel sheet using "this.downloadXLS()" in React Highcharts. It's downloading my excel sheet but I am getting some "chart" label in the downloaded excel sheet (In A1 Row of excel) like this....
Reference Image:…

Maulik Patel
- 344
- 1
- 10
0
votes
1 answer
Iterate through an i18next JSON file to map data in a Class Component
I have been trying to refactor code from data being set manually to mapping through a JSON file, more specifically translations using i18next.
Here is what the code looked like:
constructor(props) {
super(props)
var p1 =

Jonathan Buso
- 13
- 4
0
votes
0 answers
How to fix an expected a class/function error?
I'm upgrading a react native app to version 72.3 using the upgrade helper here. What I notice is the initial app screen loads without issue. But once I trigger a navigation to a new screen using @react-navigation/bottom-tabs@6.5.8's - Tab.Screen…

Brian Var
- 6,029
- 25
- 114
- 212
0
votes
0 answers
How to rerender a page in React class component based on two tokens with spanids at a time
I have a records data where certain tokens have spanid. I first want to display all the tokens along with label names when the tokens have that and this part will stay or rerendered at all times. Below all the tokens, I want to display two tokens…

Priyankar Bose
- 1
- 4
0
votes
1 answer
Prevent renders when updated state is same as previous
Is there a react lifecycle method that we can use to perform a re-render only when the updated state is different from the previous state. For example, in the following code:
class App extends Component {
constructor() {
super();
…

De-J
- 1
- 2
0
votes
0 answers
Controlling re-renders in react?
I have been given the task to use a react lifecycle method *other* than shouldComponentUpdate() to control re-rendering of a component. Just like how shouldComponentUpdate() can prevent re-renders if you return false, I should be able to use one of…

De-J
- 1
- 2
0
votes
1 answer
Autoforge Viewer canvas won't resize after open sibling container
I have 2 element rendering in a same parent element one of them is a parameter container that can open and close and other is forge viewer. At 876px width this parent element gets flex-direction:column ; . When i open parameters container and go…

Ender Çelik
- 5
- 3
0
votes
1 answer
Scrolling the window to specific text within a large amount of text (React)
(This is all in a class-based component)
I have a component that essentially handles dumping out a text file line by line onto the page. Each sentence of that text file is separated by a line and within its own
element like…

LessTRess
- 11
- 1
0
votes
2 answers
Ref current is ready only in class component
I am using a ref created using createRef to store a string value in a class component. However, whenever I try to change the value of current, I get the error that current is ready only. I am using typescript:
class MyClassComponent extends…

Saad Farooq
- 39
- 1
- 8
0
votes
0 answers
how to test e.stopPropagation with react testing library?
In old project I have react class component for listen key down. I try write 100% coverage test, but I don't understand how call e.isPropagationStopped
Detailed:
// my class component
class KeyListener extends Component {
handleKeyDown = (e) =>…

Roma N
- 175
- 11
0
votes
0 answers
Need code in functional component of react
I am trying to implement functional component foir ItemDragging in Recatjs but not able to fully accomplish the goal. Getting some difficulties while implementing.
import React from "react";
import List, { ItemDragging } from…
0
votes
0 answers
I need a 2nd pair of eyes to look at my code, having trouble figuring it out on my own
I'm having trouble figuring out why for some reason the my application sets isError to true... (the error is being caught even when the login is successful => when i refresh the page everything is ok). I am not sure if I explained it right, I'll be…

askingquestions41
- 21
- 1
- 3
0
votes
1 answer
React: Error passing props to functional child components inside class parent component
In my React Native app I have a class component Parent and in it I define two functional components ChildA and ChildB. This works without errors:
class Parent extends Component {
const ChildA = () => {
return

gkeenley
- 6,088
- 8
- 54
- 129