TypeError: group.users.values(...).map is not a function
sumesh1993 opened this issue · comments
sumesh1993 commented
I am getting this error in the App.js file
Following is the code
render() {
const { group } = this.props;
const selectedUser = group.users.get(this.state.selectedUser);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">WishList</h1>
</header>
<select onChange={this.onSelectUser}>
<option>- Select user -</option>
{group.users.values().map(user => (
<option key={user.id} value={user.id}>
{user.name}
</option>
))}
</select>
{selectedUser && <WishListView wishList={selectedUser.wishList} />}
</div>
);
}
This is how my index.js file looks
let initialState = {
users: {
'a342': {
id: 'a342',
name: 'Homer',
gender: 'm',
},
'5fc2': {
id: '5fc2',
name: 'Marge',
gender: 'f',
},
'663b': {
id: '663b',
name: 'Bart',
gender: 'm',
},
'65aa': {
id: '65aa',
name: 'Maggie',
gender: 'f',
},
'ba32': {
id: 'ba32',
name: 'Lisa',
gender: 'f',
},
},
};
let group = Group.create(initialState);
function renderApp() {
ReactDOM.render(<App group={group} />, document.getElementById('root'));
}
@mweststrate can u help me with this ?
Michel Weststrate commented
The project is not yet updated with the latest deps. But
Array.from(group.users.values()).map.... will fix this
Op wo 1 aug. 2018 09:10 schreef sumesh1993 <notifications@github.com>:
… I am getting this error in the App.js file
Following is the code
render() {
const { group } = this.props;
const selectedUser = group.users.get(this.state.selectedUser);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">WishList</h1>
</header>
<select onChange={this.onSelectUser}>
<option>- Select user -</option>
{group.users.values().map(user => (
<option key={user.id} value={user.id}>
{user.name}
</option>
))}
</select>
{selectedUser && <WishListView wishList={selectedUser.wishList} />}
</div>
);
}
This is how my index.js file looks
let initialState = {
users: {
'a342': {
id: 'a342',
name: 'Homer',
gender: 'm',
},
'5fc2': {
id: '5fc2',
name: 'Marge',
gender: 'f',
},
'663b': {
id: '663b',
name: 'Bart',
gender: 'm',
},
'65aa': {
id: '65aa',
name: 'Maggie',
gender: 'f',
},
'ba32': {
id: 'ba32',
name: 'Lisa',
gender: 'f',
},
},
};
let group = Group.create(initialState);
function renderApp() {
ReactDOM.render(<App group={group} />, document.getElementById('root'));
}
@mweststrate <https://github.com/mweststrate> can u help me with this ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhNXsx6VCtxu7LJ3qtpAdIyKayrIeks5uMVR7gaJpZM4Vp9Z8>
.
sumesh1993 commented
Thank you, Fixed.