frankcollins3 / ASPIZZA

microsoft learning module
1 stars 0 forks source link

"statefulness" in razor? #10

Open frankcollins3 opened 1 year ago

frankcollins3 commented 1 year ago

attempting to do: @functions { } now working and serving string data which is created from a randomly generated value from string array. Screen Shot 2023-09-15 at 8 21 48 PM

instead of using the: @ { } block of code which is serverside C#... how to reinvoke a function from @functions { }

error: stuck as to where to go now Screen Shot 2023-09-15 at 8 21 55 PM

in a react app one could create a state variable and use this function as inline Screen Shot 2023-09-15 at 8 21 59 PM

proposed approach: find a way to store a variable to mimic state and reassign? moments like this show how perfect a concept of: state and useEffect() really is

possible improvements:

frankcollins3 commented 1 year ago

in react very easy: create string state. can create int state. increase int by one onclick which triggers an effect. the effect runs an expression to gather string value and set string state to be that value.

don't need 2 state but works well either way. [8:26pm]