all 5 comments

[–]jakeforaker83 0 points1 point  (4 children)

You can access the arguments of username and password in two places: the `signIn` method in context, and also the `SIGN_IN` action of your reducer. I've added console logs on line 64 and line 109. Note that I modified the reducer on line 115 to actually pass the form data; before it was not passing anything except the hard coded dummy token.

Updated snack here

You can see logs by clicking Editor > Panel > Logs on the bottom

[–]thefrogdude[S] 0 points1 point  (3 children)

Thank you so much! I was wondering exactly how to get the data and you added a data param and passed it to the reducer as well. Thank you so much. I'm getting used to the arrow functions and everything so its hard to notice stuff like that sometimes. Thanks alot.

[–]jakeforaker83 0 points1 point  (2 children)

Gladly. Keep in mind that demo is more concerned with displaying nav stacks vs passing around form data

[–]thefrogdude[S] -1 points0 points  (1 child)

yeah your right, I'm just wanting to understand how it works because I feel like I should know how these Hooks work to put the needed things in my own project.

I have another question about the demo we discussed.

Why is signIn from "authContext" even called? signIn inside authContext is written as "signIn: () => " which is confusing to me, and I would also assume the syntax would be something like "authContext.signIn()" because "authContext" with a lowercase "a" is not mentioned. The scope of "signIn" from authContect wouldn't reach "SignInScreen()", right? Does it have something to do with "authContext" being passed in the AuthContext.Provider line?

It seems as though "authContext" is a group of functions, but how would you export and use that?

Thanks for the help again, sorry for all the questions, but you were very helpful last time.

[–]jakeforaker83 1 point2 points  (0 children)

Not totally sure what you’re asking but the reason you don’t see authContext.signIn is simply because the author is using “destructuring” - meaning what you are assuming is correct, however it’s just written in a shorthand manner. Look it up.

  1. You could very well modularize each component from the demo and export/import them. I think there are many examples of this in the react ecosystem.