All Questions
476,973 questions
2567 votes
72 answers
3.5m views
Error message "error:0308010C:digital envelope routines::unsupported"
I created the default IntelliJ IDEA React project and got this: Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:67:19) at Object.createHash (...
2375 votes
51 answers
1.8m views
How can I 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 navigation. Not from a ...
2099 votes
88 answers
2.2m views
Loop inside React JSX
I'm trying to do something like the following in React JSX (where ObjectRow is a separate component): <tbody> for (var i=0; i < numrows; i++) { <ObjectRow/> } </...
1499 votes
21 answers
661k views
What are these three dots in React doing?
What does the ... do in this React (using JSX) code and what is it called? <Modal {...this.props} title='Modal heading' animation={false}>
1465 votes
33 answers
1.0m 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 ...
1306 votes
63 answers
916k 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 ...
1136 votes
24 answers
1.7m views
Can you force a React component to rerender without calling setState?
I have an external (to the component), observable object that I want to listen for changes on. When the object is updated it emits change events, and then I want to rerender the component when any ...
1124 votes
8 answers
283k views
Why use Redux over Facebook Flux? [closed]
I've read this answer, reducing boilerplate, looked at few GitHub examples and even tried redux a little bit (todo apps). As I understand, official redux doc motivations provide pros comparing to ...
1103 votes
15 answers
439k views
Difference between npx and npm?
I have just started learning React, and Facebook helps in simplifying the initial setup by providing the following ready-made project. If I have to install the skeleton project I have to type npx ...
1097 votes
29 answers
786k views
How do I conditionally add attributes to React components?
Is there a way to only add attributes to a React component if a certain condition is met? I'm supposed to add required and readOnly attributes to form elements based on an Ajax call after render, but ...
1095 votes
32 answers
1.4m 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 ...
995 votes
28 answers
1.2m views
How to set focus on an input field after rendering?
What's the react way of setting focus on a particular text field after the component is rendered? Documentation seems to suggest using refs, e.g: Set ref="nameInput" on my input field in the render ...
976 votes
24 answers
891k 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() { ...
937 votes
57 answers
1.0m views
Detect click outside React component
I'm looking for a way to detect if a click event happened outside of a component, as described in this article. jQuery closest() is used to see if the target from a click event has the dom element as ...
927 votes
38 answers
916k views
React js onClick can't pass value to method
I want to read the onClick event value properties. But when I click on it, I see something like this on the console: SyntheticMouseEvent {dispatchConfig: Object, dispatchMarker: ".1.1.0.2.0.0:1", ...