Export import in reactjs

Say I have class Panels and class Panel in my ui. I want to avoid multiple statements such as import Panel.. and import Panels ... every time I decide to use them. Instead, I want to re-export Panel from Panels once, and in my app just say somethin...
more »

2017-08-17 23:08 (2) Answers

Simplifying repeated code in React

It there a best practice to simplify something like the following in React? getInitialState: function () { return { checkbox1: false, checkbox2: false, checkbox3: false, ... }; }, selectCheckbox1: function () { this.setState({...
more »

2017-08-17 22:08 (3) Answers

How to use state as checked atribute in ReactJs?

I'm using a switch checkbox in render, so one important attribute to detect if it's checked or not is defaultChecked. I set the state previously in the componentWillReceiveProps. I try first putting the state as attribute but I'm getting an error Une...
more »

2017-08-17 20:08 (4) Answers

Use of dropzone-react-component with redux form

I'm using react to design a simple webpage uploading multiple images using dropzone-react-component and submitting to a server using reducer-dispatcher pattern (REDUX). Stuck on how to pass on my file blobs or array of files queued up in dropzone to...
more »

2017-08-17 15:08 (0) Answers

Question mark inside react router path

I'm trying to pass parameter inside my url, but i have problem with reading. I'm using react-router v4. URL: http://localhost:3000/reset?token=123 I'm trying to read it this way: <Route path="/reset?token=:token" component={Reset}/> B...
more »

2017-08-17 11:08 (0) Answers

React rendering user list in child component

In my parent component (a search bar component) I have this code which passes an array down to the child component: When form is submitted I make am axios request to my back-end database async onFormSubmit(event) { event.preventDefault(); c...
more »

2017-08-16 23:08 (2) Answers

Component won't recognize it's being exported

I've encountered a very strange error. I feel that I've exported the Home component in a normal and conventional manner. Below, I've posted the .js files that I think are relevant in order to rectify this error. Despite this, In my iOS simulator, ...
more »

2017-08-16 16:08 (1) Answers

How to hide ghost image in reactjs drag event?

I'm using onDrag method in react js. I want to happen drag while i'm dragging the image, but I don't want to show the ghost image. I used css "-webkit-user-drag:none", but it is completely prevent the drag functionality. I want both to work in same t...
more »

2017-08-16 09:08 (1) Answers

Apply changes according to div id

I have a div mapped so it would render any number of times according to data sent from the database. And on componentDidMount i'm getting an id. I want to change background color of the div which matches the id i'm getting from componentDidMount How ...
more »

2017-08-16 07:08 (2) Answers

Asynchronous xmlhttp request in react

I am trying to implement asynchronous XMLHttpRequest in react. Here is my attempt: var xhr = new XMLHttpRequest(); var json_obj, status = false; xhr.open("GET", "https://jsonplaceholder.typicode.com/photos/", true); xhr.onload = function (e) ...
more »

2017-08-15 23:08 (4) Answers