Skip to content
Advertisement

Tag: react-hooks

Using use-State hook in react function always throws an error + How to share a variable with another component

I’m a beginner to programming in Javascript/Typescript and just about to develop my very first app in react. To get some data from the backend (FastAPI) I created the function “GetData” that is executed whenever the button is clicked. Component 1: Button import { GetData } from “./socket” Component 2 (named socket): websocket and data logic The problem I’m facing

ReactJS double render for a Boolean state with useState

I’m just playing around with ReactJS and trying to figure out some strange behavior with the useState hook. A component should not re-rendered if the state is set with the same primitive value (Boolean) as it was before here is the console output – you can see the component and the hook are both rendered two times with “true” (after

Advertisement