ku6ryo / ReactPrompt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Demo of a simple react component that simulates window.prompt(). The concept is opening a modal with a function. Usually you would use a state variable to control the modal, but this is a more declarative approach.

function App() {
  const { open, prompt } = usePrompt()
  return (
   <>
     <button
       onClick={() => prompt('initial value value')}
     >
       Open prompt
     </button>
     {prompt}
   </>
  )
}

screenshot

About


Languages

Language:TypeScript 83.3%Language:HTML 9.1%Language:SCSS 7.6%