talkgroup

react learning notes while coding on twodays-crossing

this is a “side effect”
new react hook: useEffect
this is a hook you m ight want to use in your apps when you want to communicate with a server (doing something async), or activate a printer, or something.
it’s something happening in the world when you don’t know how long it’s gonna take.
dont’ wanna get caught in a render loop.
it might change your app in some way

counterpoint: it’s just posting a new message, which uses useDocument, not useEffect

REACT BRAIN! lol

first stab =)

  // callback, dependency array (when these values change, run this effect... which is the callback)
  React.useEffect(() => {
    console.log("🐠 changeNick was called with " + newNick);
  }, []);
  // hmm, this would get called every time a message changed 
  // it is associated with rendering. this would trigger a nickname change every
  // time and you'd have to put conditions on top of it 
    //hooks: same number of them AND the same order. 
    //that's why it doesn't work if you call a hook after a condition. 
    // -- cuz it might run in a different order 
    // --also doens;'t work in a conditional

a “windup” animates the text where characters come in one by one lol
import { useWindupString } from ‘windups’;
//const [woundUpButtonLabel, ] = useWindupString(getButtonLabel());

1 Like