Skip to main content
Stack Overflow for Teams is now Stack Internal: See how we’re powering the human intelligence layer of enterprise AI. Read more >
Filter by
Sorted by
Tagged with
0 votes
1 answer
32 views

How to implement webworker with React class component where the worker file imports both custom and react modules

I am working with exceljs and file-saver modules to download the given data in excel. When I click the button on UI, it will call a web-worker which has the imports and excel preparation logic. I am ...
Jayanth's user avatar
0 votes
0 answers
12 views

componentWillUnmount getting triggered from a component which is already unmounted

I was looking into the 'componentWillUnmount' method in this page https://www.w3schools.com/react/showreact.asp?filename=demo2_react_lifecycle_componentwillunmount The issue which I noticed is that ...
Jefin Mathew's user avatar
1 vote
0 answers
42 views

Textarea - cursor moves to end - react

As I type something in textarea, it works fine. But when I try to take cursor back to add/edit some text, after typing one character it moves to the end. Code: React.createElement('textarea', { ...
Dragut's user avatar
  • 137
0 votes
1 answer
39 views

UNSAFE_componentWillReceiveProps(nextProps) in functional component

I have a class based component as below: class NeedsApprovalEditTransactionInfoContainer extends React.Component { UNSAFE_componentWillReceiveProps(nextProps) { if ( nextProps....
coder hard's user avatar
0 votes
1 answer
42 views

How to convert prevState of class component into functional component

Below is a class based component example class TestContainer extends React.Component { constructor(props) { super(props); this.state = { attached: initializeObject(...
khan's user avatar
  • 119
1 vote
1 answer
97 views

Textarea not updating in my Markdown Previewer

I've been working on this Markdown Previewer to improve my skills in JavaScript and React and I've run into an issue I can't solve. I don't know if I've just been staring at it too long or what. ...
Brady Brown's user avatar
2 votes
1 answer
153 views

react-network-vis diagram is automatically set to network.fit()

im my react-network-vis diagram im postioning my nodes with the values saved in database and it working properly. after loading the the nodes if try to go to some other page and came back all the ...
Sindujan Nirmalan's user avatar
0 votes
1 answer
58 views

reactjs- A custom function that passed as a prop into an component that inside of map function doesn't work

I am doing a to-do app but with Class Components in React because I wanted to learn logic of state before Hooks. I have only one index.js file so it's not that complicated. These are my packages: var ...
Alim Gölcük's user avatar
0 votes
0 answers
203 views

Class component bind vs. function component useCallback

For comparison purpose I wrote same logic as class vs. function component, and noticed some behavioral differences. Class component with bind: this.logName = this.logName.bind(this); then function ...
Deepak Sharma's user avatar
0 votes
0 answers
62 views

Getting Error 'Error getting locale from store!'

In my react application, I am using class components with redux react-redux-18n libraries and some of the times we are getting below errors in my browser console Please help me with solution. Here is ...
mohan bhonu's user avatar
0 votes
1 answer
278 views

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 ...
Maulik Bhalani's user avatar
0 votes
1 answer
49 views

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 ...
De-J's user avatar
  • 3
0 votes
0 answers
47 views

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 ...
De-J's user avatar
  • 3
0 votes
1 answer
135 views

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:...
Ender Çelik's user avatar
2 votes
1 answer
2k views

React extends for function component?

I have a class component that extends another class component: export default class MyLittleComponent extends TheBigBoy Now I need to refactor MyLittleComponent to functional component so it works ...
Wordpressor's user avatar
  • 7,563
0 votes
1 answer
1k views

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 ...
LessTRess's user avatar
0 votes
2 answers
1k views

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 ...
Saad Farooq's user avatar
0 votes
0 answers
190 views

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 ...
Roma N's user avatar
  • 320
0 votes
0 answers
36 views

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"; ...
Sachin Kanhere's user avatar
0 votes
1 answer
25 views

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 = () =&...
gkeenley's user avatar
  • 7,648
1 vote
0 answers
85 views

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 ...
danipereiracodes's user avatar
1 vote
0 answers
407 views

React - Intersection Observer in Class-Based Component

I am working on a bar website for a friend and I have a problem: Right after the hero section of this menu page, there is a category-selector, which should have navigational buttons to the left and ...
Feldmanovitch's user avatar
1 vote
1 answer
180 views

Is it better to put new functions inside or outside React lifecycle methods?

In a react class component, I have a new function to add to a lifecycle method. I am trying to figure out if it is better to have: componentDidUpdate() { const myFunc = () => { // Do ...
Ryan Williams's user avatar
0 votes
2 answers
335 views

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 ...
Gareema's user avatar
  • 31
0 votes
1 answer
787 views

React - passing props into a Class component via a <Link>

I'm trying to pass props from one component into a Class component via a <Link> using React-Router.... But I'm having trouble... I have this code in one component wrapping text/image: <Link ...
Rob BB's user avatar
  • 1
-1 votes
2 answers
344 views

how to import a function in react class component to using it multiple times?

for example i want to add a function to return or do something like this: export const useExample = (name) => { const script = "hi" + " " + name; return script }; and i want ...
underthewater's user avatar
0 votes
1 answer
1k views

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 ...
Jorge L's user avatar
  • 11
0 votes
1 answer
65 views

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: ...
Pratik Chitte's user avatar
0 votes
1 answer
354 views

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 ...
Rihab sabri's user avatar
0 votes
2 answers
91 views

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"; ...
user20183888's user avatar
-1 votes
1 answer
122 views

Change selected value programmatically in React class based component

I am using a React class based component and material UI to display the dropdown. I am originally setting a default value and the select dropdown values get changed according to user click. However, I ...
user13569341's user avatar
0 votes
0 answers
78 views

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....
BRDroid's user avatar
  • 4,448
2 votes
1 answer
485 views

Call function of Context in react class component

I have following Code in my Context.js: import { createContext, useEffect, useReducer } from "react"; import Reducer from "./Reducer"; const INITIAL_STATE = { user: JSON.parse(...
UnknownInnocent's user avatar
0 votes
1 answer
39 views

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 { ...
vstoic's user avatar
  • 17
0 votes
3 answers
83 views

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(){ ...
ashish's user avatar
  • 13
0 votes
3 answers
4k views

How to change class of a div onclick in React

This is my code: render() { return ( <div className='btndiv'> <button className='btn'>Hide</button> </div> ); } When I click the button I want the ...
Maxator's user avatar
  • 65
0 votes
1 answer
30 views

Not able to set state in class component , Uncaught TypeError: Cannot read properties of undefined (reading 'setState')

while using react classcomponent , I am not able to set the states in the states section,I am trying to set a number and an array from API, I am not able to set both , the number is also showing ...
Tanvesh's user avatar
  • 125
1 vote
1 answer
62 views

How do I use an asynchronous function to pass data to a Select component in a React class component?

I am trying to use MenuItem components with a React class component to display an array of strings as dropdown options in a Select component. In this snippet of code, I'm trying to retrieve these ...
Mhanna112's user avatar
-1 votes
1 answer
61 views

How i convert react class based componet into functional component code in React

I am learning ReactJs and I am trying to implement below react classs based component into functional component but I am having difficulties in it. When I implement this into functional component it ...
Jenil's user avatar
  • 31
1 vote
0 answers
334 views

React Ant design file upload only xlsx file validation

beforeUpload: file => { const isPNG = file.type === 'application/vnd.ms-excel'; if (!isPNG) { message.error(`${file.name} is not a XL file`); } return isPNG || ...
Deepak Deepak's user avatar
1 vote
1 answer
45 views

Converting function in constructor to functional component in react class based component

I am trying the convert class based component to the functional component. I'm basically trying to connect to a socket and I couldn't come up with a solution on how to separate this function. ...
Baloylu_unzi's user avatar
1 vote
4 answers
75 views

Converting class based component into functional based component and using react hooks

I am learning ReactJs and I am trying to implement below react classs based component into functional component but I am having difficulties in it. When I implement this into functional component it ...
Prince Singh's user avatar
0 votes
2 answers
69 views

Is `this.props` possible to be changed in the component itself?

As the title says, is this.props possible to be changed in the component itself whether manually or automatically manual change example this.props.someData = 'some value' I don't know how to change ...
wychoi's user avatar
  • 67
0 votes
1 answer
623 views

How can I split a custom data table up into modular components?

i'm looking for some guidance to what would be considered best practice when developing a custom data table. Background: I've been tasked with created a table component that has both static and ...
stacker's user avatar
  • 263
1 vote
0 answers
41 views

React Native: Why is shouldComponentUpdate being called when neither props nor state have changed?

In my React Native app I have a PureComponent where I log whether props or state have changed each time shouldComponentUpdate() is called, like this: shouldComponentUpdate(nextProps, nextState) { ...
gkeenley's user avatar
  • 7,648
0 votes
1 answer
1k views

What is the difference between rcc and rfc in react?

I want a use case example of when react class components are needed for a project over a react functional component and vise versa. I cant seem to understand the difference between the two.
ROSBY ASIAMAH's user avatar
0 votes
1 answer
228 views

Converting DraftJS class component to Functional component

The following Draftjs code is in class component. The plugins like CreateImage, Focus Plugin, and BlockDndPlugin are being imported from the DraftJS. I would be grateful if somebody can convert the ...
Huzaifa Khalid's user avatar
1 vote
1 answer
475 views

componentWillUnmount called before component unmounts

I'm trying to understand when componentWillUnmount is called. I have this class-based component: class ClassComponent extends React.Component { constructor(props) { super(props); ...
Sam's user avatar
  • 61
0 votes
1 answer
557 views

Redux doesn't work in React Native - class component

this view doesn't work with redux, i need use redux dispatch inside react class component, but i get error "Invalid hook call. Hooks can only be called inside of the body of a function component....
Cristian Romero's user avatar
0 votes
1 answer
38 views

Array map method is not showing list in Class Based Component in React [duplicate]

I have Parent component FoodBox.js and it's child component FoodItems.js. I'm trying make a list of food items stored in the parent comp. and using map() method for it but <ul> is showing empty. ...
Mohit's user avatar
  • 137

1
2 3 4 5