Mobx-state-tree action is undefined when passed to onPress
Link to full code of current branch
With mobx-state-tree, can you not use actions as functions for onPress?
Error on ExpoGo: Uncaught Error player.removeLifePoints is not a function (it is undefined)
Here is the Player model I have prototyped.
As I dig into it more, I think it might be I am misunderstanding how to use the setter actions like with .actions(withSetPropAction), but reading the docs on it, I still am struggling to understand.
GitHub
GitHub - mchisolm0/CountApp at player-grid
Contribute to mchisolm0/CountApp development by creating an account on GitHub.
Solution:Jump to solution
Okay, I’ve got it working. I needed to switch back to passing the player using
player={player}
and then set up the typing for the props using interface.
```
interface AddLifePointsButtonProps {
player: Player
}...1 Reply
Solution
Okay, I’ve got it working. I needed to switch back to passing the player using
player={player}
and then set up the typing for the props using interface.
If someone is willing to help me understand why this is better or different than setting the type inside the component definition, I would appreciate it.