Skip to content

Tag: reactjs

how to pass an object as a prop in nextjs

I cant quite figure out how I am supposed to pass an object as a prop when using useState in Next JS. I have a lorem ipsum generator that I created in javascript functions. I have a component called Paragraphs that houses it. I need to pass in two properties, a number of paragraphs. a sentence length. The par…

Typescript dynamically infer type from object

I have a JS Object with React components, indexed by ID. I would like to have a ModalEntity type which results in this: My problem is, I want the type to be dynamically generated from the MODAL_ENTITIES object, since I want the process of adding a modal to be as effortlessly as possible. Is there a way to def…

React and JS closure issue

Background of the problem I have a simple “Ticker” class that can hold a single callback, and execute that callback each ~1s via setInterval The code is as follows. I have a React Functional Component in a nother file, that instantiates a Ticker Object, at class level(I.E outside the functional co…