Skip to content

Wrong types with mobx values() result in Getting started tutorial #1981

Answered by EmilTholin
alexamy asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @alexamy!

You can use the values method on your map to get an iterator object and then create an array from that to retain the type information:

export default function App() {
  return (
    <div className='App'>
      {Array.from(store.todos.values()).map((todo, i) => (
        <p key={i}>{todo.name}</p>
      ))}
    </div>
  );
}

Nice find though, we should consider updating the documentation to retain the type information, even though the example is in plain JavaScript.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@alexamy
Comment options

@alexamy
Comment options

@EmilTholin
Comment options

Answer selected by alexamy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants