How to pass a function as a prop in React+Typescript?

Hi! I am a newbie in Typescript: changeuser prop throws me an error “Type ‘{ changeUser: () => void; }’ is not assignable to type ‘IntrinsicAttributes’.” Any ideas, how to fix it?

const App = () => {

const [user, setUser] = useState(localStorage.getItem(‘user’) ? JSON.parse(localStorage.getItem(‘user’) || “”) : “”);

const changeUser = ():void => {

setUser("");

localStorage.removeItem(“user”);

}

return (

<div className="App">

 {user.length < 1 ?

//  <AddRestaurantPage/>

   <AuthorizationPage />

  : <SelectedRestaurantPage changeUser={changeUser}/> }

</div>

);

}

I’ve found my problem, sorry. Delete post, please

Please delete, i’ve found an answer

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.