how to display records in a dropdown using react redux
up vote
0
down vote
favorite
Am using the code below to display records in reaxt redux, everything works fine. now I want to display the result in
a dropdown like in the code below but cannot get it to work.
<select name="form-field-name" value={user.firstName} onChange={this.handleChange}/>
<option value="{user.id}"> {user.firstName + ' ' + user.lastName} </option></select>
here is the main code
import React from 'react';
import { Link } from 'react-router-dom';
import { connect } from 'react-redux';
import { dropdownActions } from '../_actions';
class DropdownApp extends React.Component {
constructor(props) {
super(props);
this.state = {
us: 0
};
}
componentDidMount() {
this.props.dispatch(userActions.DropdownRecords());
}
handleDeleteUser(id) {
return (e) => this.props.dispatch(userActions.delete(id));
}
render() {
const { user, users } = this.props;
return (
<div style={{background:'green'}} className="well col-md-6 col-md-offset-3">
{users.items &&
<ul>
{users.items.map((user, index) =>
<li key={user.id}>
/*
<select name="form-field-name" value={user.firstName} onChange={this.handleChange}/>
<option value="{user.id}"> {user.firstName + ' ' + user.lastName} </option></select>
*/
{user.firstName + ' ' + user.lastName}
</li>
)}
</ul>
}
<p>
hello
</p>
</div>
);
}
}
reactjs redux
add a comment |
up vote
0
down vote
favorite
Am using the code below to display records in reaxt redux, everything works fine. now I want to display the result in
a dropdown like in the code below but cannot get it to work.
<select name="form-field-name" value={user.firstName} onChange={this.handleChange}/>
<option value="{user.id}"> {user.firstName + ' ' + user.lastName} </option></select>
here is the main code
import React from 'react';
import { Link } from 'react-router-dom';
import { connect } from 'react-redux';
import { dropdownActions } from '../_actions';
class DropdownApp extends React.Component {
constructor(props) {
super(props);
this.state = {
us: 0
};
}
componentDidMount() {
this.props.dispatch(userActions.DropdownRecords());
}
handleDeleteUser(id) {
return (e) => this.props.dispatch(userActions.delete(id));
}
render() {
const { user, users } = this.props;
return (
<div style={{background:'green'}} className="well col-md-6 col-md-offset-3">
{users.items &&
<ul>
{users.items.map((user, index) =>
<li key={user.id}>
/*
<select name="form-field-name" value={user.firstName} onChange={this.handleChange}/>
<option value="{user.id}"> {user.firstName + ' ' + user.lastName} </option></select>
*/
{user.firstName + ' ' + user.lastName}
</li>
)}
</ul>
}
<p>
hello
</p>
</div>
);
}
}
reactjs redux
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Am using the code below to display records in reaxt redux, everything works fine. now I want to display the result in
a dropdown like in the code below but cannot get it to work.
<select name="form-field-name" value={user.firstName} onChange={this.handleChange}/>
<option value="{user.id}"> {user.firstName + ' ' + user.lastName} </option></select>
here is the main code
import React from 'react';
import { Link } from 'react-router-dom';
import { connect } from 'react-redux';
import { dropdownActions } from '../_actions';
class DropdownApp extends React.Component {
constructor(props) {
super(props);
this.state = {
us: 0
};
}
componentDidMount() {
this.props.dispatch(userActions.DropdownRecords());
}
handleDeleteUser(id) {
return (e) => this.props.dispatch(userActions.delete(id));
}
render() {
const { user, users } = this.props;
return (
<div style={{background:'green'}} className="well col-md-6 col-md-offset-3">
{users.items &&
<ul>
{users.items.map((user, index) =>
<li key={user.id}>
/*
<select name="form-field-name" value={user.firstName} onChange={this.handleChange}/>
<option value="{user.id}"> {user.firstName + ' ' + user.lastName} </option></select>
*/
{user.firstName + ' ' + user.lastName}
</li>
)}
</ul>
}
<p>
hello
</p>
</div>
);
}
}
reactjs redux
Am using the code below to display records in reaxt redux, everything works fine. now I want to display the result in
a dropdown like in the code below but cannot get it to work.
<select name="form-field-name" value={user.firstName} onChange={this.handleChange}/>
<option value="{user.id}"> {user.firstName + ' ' + user.lastName} </option></select>
here is the main code
import React from 'react';
import { Link } from 'react-router-dom';
import { connect } from 'react-redux';
import { dropdownActions } from '../_actions';
class DropdownApp extends React.Component {
constructor(props) {
super(props);
this.state = {
us: 0
};
}
componentDidMount() {
this.props.dispatch(userActions.DropdownRecords());
}
handleDeleteUser(id) {
return (e) => this.props.dispatch(userActions.delete(id));
}
render() {
const { user, users } = this.props;
return (
<div style={{background:'green'}} className="well col-md-6 col-md-offset-3">
{users.items &&
<ul>
{users.items.map((user, index) =>
<li key={user.id}>
/*
<select name="form-field-name" value={user.firstName} onChange={this.handleChange}/>
<option value="{user.id}"> {user.firstName + ' ' + user.lastName} </option></select>
*/
{user.firstName + ' ' + user.lastName}
</li>
)}
</ul>
}
<p>
hello
</p>
</div>
);
}
}
reactjs redux
reactjs redux
asked Nov 8 at 19:32
jmarkatti
7017
7017
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
This is how I was able to resolve it
<select>
<option value='' >--select--</option>
{users.items.map((user, index) =>
<option key={user.id} value='{ user.id }' >{ user.lastName}</option>
)}
</select>
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
This is how I was able to resolve it
<select>
<option value='' >--select--</option>
{users.items.map((user, index) =>
<option key={user.id} value='{ user.id }' >{ user.lastName}</option>
)}
</select>
add a comment |
up vote
0
down vote
accepted
This is how I was able to resolve it
<select>
<option value='' >--select--</option>
{users.items.map((user, index) =>
<option key={user.id} value='{ user.id }' >{ user.lastName}</option>
)}
</select>
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
This is how I was able to resolve it
<select>
<option value='' >--select--</option>
{users.items.map((user, index) =>
<option key={user.id} value='{ user.id }' >{ user.lastName}</option>
)}
</select>
This is how I was able to resolve it
<select>
<option value='' >--select--</option>
{users.items.map((user, index) =>
<option key={user.id} value='{ user.id }' >{ user.lastName}</option>
)}
</select>
answered Nov 8 at 20:29
jmarkatti
7017
7017
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214906%2fhow-to-display-records-in-a-dropdown-using-react-redux%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown