Tag: javascript

62 votes
4 answers
2.4K views
In what situations would AJAX long/short polling be preferred over HTML5 WebSockets?

I am building a small chat application for friends, but unsure about how to get information in a timely manner

avatar
Georgie
0 1 0 9
asked 07 September, 2021
55 votes
21 answers
411 views
React Js conditionally applying class attributes

I want to conditionally show and hide this button group depending on what is passed in from the parent compone

avatar
Chelsea
0 1 0 9
asked 07 September, 2021
55 votes
13 answers
1.2K views
Invariant Violation: _registerComponent(...): Target container is not a DOM element

I get this error after a making trivial React example page: Uncaught Error: Invariant Violation: _register

avatar
Luis
0 1 0 9
asked 07 September, 2021
61 votes
16 answers
1.2K views
Setting a backgroundImage With React Inline Styles

I'm trying to access a static image to use within an inline backgroundImage property within React. Unfort

avatar
Kurtis
0 1 0 9
asked 07 September, 2021
52 votes
21 answers
3.1K views
Rerender view on browser resize with React

How can I get React to re-render the view when the browser window is resized? Background I have some blocks

avatar
Dusty
0 1 0 9
asked 07 September, 2021
58 votes
20 answers
856 views
React "after render" code?

I have an app where I need to set the height of an element (lets say "app-content") dynamically. It takes the

avatar
Jefferey
0 1 0 9
asked 07 September, 2021
56 votes
15 answers
1.7K views
useState set method not reflecting change immediately

I am trying to learn hooks and the useState method has made me confused. I am assigning an initial value to a

avatar
Deedee
0 1 0 9
asked 07 September, 2021
66 votes
13 answers
2.4K views
Error Running React Native App From Terminal (iOS)

I am following the tutorial on the official React Native website. Using the following to build my project: r

avatar
Corey
0 1 0 9
asked 07 September, 2021
47 votes
30 answers
2.7K views
Invariant Violation: Objects are not valid as a React child

In my component's render function I have: render() { const items = ['EN', 'IT',

avatar
Suzan
0 1 0 9
asked 07 September, 2021
67 votes
16 answers
1.1K views
React - changing an uncontrolled input

I have a simple react component with the form which I believe to have one controlled input: import React from

avatar
Kurtis
0 1 0 9
asked 07 September, 2021
69 votes
18 answers
548 views
How can I update the parent's state in React?

My structure looks as follows: Component 1 - |- Component 2 - - |- Component 4 - - - |- Component 5

avatar
Stacia
0 1 0 9
asked 07 September, 2021
57 votes
30 answers
2.6K views
How to add multiple classes to a ReactJS Component?

I am new to ReactJS and JSX and I am having a little problem with the code below. I am trying to add multipl

avatar
Forrest
0 1 0 9
asked 07 September, 2021
59 votes
14 answers
1.3K views
React JSX: selecting "selected" on selected <select> option

In a React component for a <select> menu, I need to set the selected attribute on the option that reflec

avatar
Gigi
0 1 0 9
asked 07 September, 2021
52 votes
16 answers
608 views
Correct modification of state arrays in React.js

I want to add an element to the end of a state array, is this the correct way to do it? this.state.arrayvar.pu

avatar
Dorian
0 1 0 9
asked 07 September, 2021
63 votes
30 answers
2.3K views
How to update nested state properties in React

I'm trying to organize my state by using nested property like this: this.state = { someProperty: {

avatar
Thurman
0 1 0 9
asked 07 September, 2021
44 votes
16 answers
1.3K views
Parse Error: Adjacent JSX elements must be wrapped in an enclosing tag

I am trying to set up my React.js app so that it only renders if a variable I have set is true. The way my

avatar
Yolando
0 1 0 9
asked 07 September, 2021
54 votes
9 answers
1.1K views
Pros/cons of using redux-saga with ES6 generators vs redux-thunk with ES2017 async/await

There is a lot of talk about the latest kid in redux town right now, redux-saga/redux-saga. It uses generator

avatar
Stacia
0 1 0 9
asked 07 September, 2021
60 votes
7 answers
2K views
ReactJS - Does render get called any time "setState" is called?

Does React re-render all components and sub components every time setState() is called? If so, why? I thought

avatar
Freida
0 1 0 9
asked 07 September, 2021
59 votes
30 answers
671 views
Perform debounce in React.js

How do you perform debounce in React.js? I want to debounce the handleOnChange. I tried with debounce(this.h

avatar
Nereida
0 1 0 9
asked 07 September, 2021