mweststrate / mst-course

Lesson sources for "Manage Application State with Mobx-state-tree" course

Home Page:https://egghead.io/courses/manage-application-state-with-mobx-state-tree

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: group.users.values(...).map is not a function

sumesh1993 opened this issue · comments

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 ?

Thank you, Fixed.