score:0

Accepted answer

okay the entire thing started with that i got an error saying

typeerror: cannot read property 'fornavn' of null

this made no sense to me because when i console.log the whole thing fornavn (fistname in danish) was there

 useeffect(() => {
  authenticationservice.currentuser.subscribe(z => {
    console.log(z)
    setcurrentuser(z);
    setname(z.fornavn)
    
  });
 
}, [])

so i tried to get the response from the login function witch gave me even more problems the solution to my problem was however to set an if statement in the useeffect like so:

useeffect(() => {
  authenticationservice.currentuser.subscribe(z => {
    if(z === null){
      setcurrentuser(null);
      setname(null);
    }else{
      setcurrentuser(z);
      setname(z.fornavn);
    }
   
  });
 
}, [currentuser])

and now it works..

score:0

it looks like you have the prop defined as firstname in the parent component, and firstname in the child component? if that's accurate, it would cause an error.

as a side note, the way you name your functions does not make it very obvious that they are in fact functions. i would name the function firstname something like handleupdatefirstname or onchangefirstname for example. or...better yet, just pass setname as a prop. you are essentially just redefining it here:

firstname={fornavn => setname(fornavn)}

i would look into using proptypes for your components - it will tell you if you have a missing or mislabeled prop.

edit: example of passing setstate as a prop:

const child = ({name, setname}) => (
  <div>
    <h1>edit name</h1>
    <input value={name} onchange={e => setname(e.target.value)}/>
  </div>
)

const parent = () => {
  const [ name, setname ] = usestate('')
  return (
    <child name={name} setname={setname}/>
  )
  
}

Related Query

More Query from same tag