365体育足球滚球比分

Questions tagged [reactjs]

365体育足球滚球比分 React (also known as React.js or ReactJS) is a JavaScript library developed by Facebook for building user interfaces. It uses a declarative, component-based paradigm and aims to be both efficient and flexible.

Filter by
Sorted by
Tagged with
150
votes
4answers
84k 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 state in the form of an array. The set method in useState is not working for me even with ...
1464
votes
33answers
754k views

Programmatically navigate using react router

With react-router I can use the Link element to create links which are natively handled by react router. I see internally it calls this.context.transitionTo(...). I want to do a navigation. Not ...
216
votes
19answers
65k views

Unable to access React instance (this) inside event handler [duplicate]

I am writing a simple component in ES6 (with BabelJS), and functions this.setState is not working. Typical errors include something like Cannot read property 'setState' of undefined or this....
95
votes
11answers
56k views

setState doesn't update the state immediately

I would like to ask why my state is not changing when I do an onclick event. I've search a while ago that I need to bind the onclick function in constructor but still the state is not updating. Here's ...
673
votes
43answers
334k views

React-router urls don't work when refreshing or writing manually

I'm using React-router and it works fine while I'm clicking on link buttons, but when I refresh my webpage it does not load what I want. For instance, I am in localhost/joblist and everything is fine ...
329
votes
7answers
168k views

Why calling react setState method doesn't mutate the state immediately?

I'm reading Forms section of reactjs documentation and just tried this code to demonstrate onChange usage (JSBIN). var React= require('react'); var ControlledForm= React.createClass({ ...
667
votes
12answers
618k views

Understanding unique keys for array children in React.js

I'm building a React component that accepts a JSON data source and creates a sortable table. Each of the dynamic data rows has a unique key assigned to it but I'm still getting an error of: Each ...
400
votes
25answers
247k 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: { flag:true } } But updating state like this, this.setState({ someProperty.flag: false })...
213
votes
10answers
255k views

How to pass data from child component to its parent in ReactJS?

I'm trying to send data from a child component to it's parent as follow: const ParentComponent = React.createClass({ getInitialState() { return { language: '', }; }...
45
votes
3answers
8k views

Why calling setState method doesn't mutate the state immediately?

Ok, i'll try and make this quick because it SHOULD be an easy fix... I've read a bunch of similar questions, and the answer seems to be quite obvious. Nothing I would ever have to look up in the ...
428
votes
13answers
447k views

Correct modification of state arrays in ReactJS

I want to add an element to the end of a state array, is this the correct way to do it? this.state.arrayvar.push(newelement); this.setState({arrayvar:this.state.arrayvar}); I am concerned that ...
46
votes
8answers
19k views

Programmatically Navigate using react-router

I am developing an application in which I check if the user is not loggedIn. I have to display the login form, else dispatch an action that would change the route and load other component. Here is my ...
488
votes
16answers
324k views

Call child method from parent

I have two components. Parent component Child component I was trying to call child's method from Parent, I tried this way but couldn't get a result class Parent extends Component { render() { ...
181
votes
4answers
87k views

How to use arrow functions (public class fields) as class methods?

I'm new to using ES6 classes with React, previously I've been binding my methods to the current object (show in first example), but does ES6 allow me to permanently bind a class function to a class ...
901
votes
24answers
428k views

How to pass props to {this.props.children}

I'm trying to find the proper way to define some components which could be used in a generic way: <Parent> <Child value="1"> <Child value="2"> </Parent> There is a logic ...

15 30 50 per page
1
2 3 4 5
768