You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes when writing actions or components, it can be a good idea to split the logic that accesses the universe into reusable functions. For example, if I have the following few lines throughout my code,
However, this does not work. The transpiler recognizes that the getCurrentGame function uses the state and turns in into an action. To make this work I need to pass the state varaible.
This is fairly unintuitive because state is imported at the file level, but then needs to be passed from the action to a helper function. The example above is in an action, but the same idea applies to accessing and watching state in a component.
I am not exactly sure how to fix this, but I expect some users will get confused by this. I know @andrejak encountered this when developing the devtools, and I have encountered when just writing example apps.
Sometimes when writing actions or components, it can be a good idea to split the logic that accesses the universe into reusable functions. For example, if I have the following few lines throughout my code,
I may want to extract it to a function
However, this does not work. The transpiler recognizes that the
getCurrentGame
function uses the state and turns in into an action. To make this work I need to pass thestate
varaible.This is fairly unintuitive because
state
is imported at the file level, but then needs to be passed from the action to a helper function. The example above is in an action, but the same idea applies to accessing and watching state in a component.I am not exactly sure how to fix this, but I expect some users will get confused by this. I know @andrejak encountered this when developing the devtools, and I have encountered when just writing example apps.
Any thoughts on the above @Onurbon?
The text was updated successfully, but these errors were encountered: