Skip to main content

useTextArea

The useTextArea hook returns the TextAreaDialogComponent component to render the TextAreaDialog and openTextAreaDialog function to open the TextAreaDialogComponent programatically.

Importing the hook


import { useTextArea } from 'repopup';

Usage


import React from 'react';
import { useTextArea , RepopupProvider } from 'repopup';
import ReactDOM from 'react-dom';


const App = () => {
const { TextAreaDialogComponent: TextAreaDialog, openTextAreaDialog } = useTextArea({
onSubmitCallback: (val: any) => console.log(val),
label: 'Message'
});
return (
<React.Fragment>
<Button onClick={() => openTextAreaDialog()}>Open</Button>
<TextAreaDialog placeholder="Write your message ..." />
</React.Fragment>
);
};

ReactDOM.render(
<RepopupProvider>
<App />
</RepopupProvider>,
,document.querySelector('#app'));


Function Signature


function useTextArea(
options: UseTextAreaArgs,
): {TextAreaDialogComponent:JSX.Element,openTextAreaDialog: () => void}

Options

OptionTypeDescriptionDefault
closeOnBackdropClickbooleanWheather or not to close the popup on clicking the backdroptrue
titlestringUsed for the title of the popup
cancelButtonTextstringUse this to change the text on the "Cancel"-button.'Cancel'
onSubmitCallback(value: any) => void;Function that will be run when the "Submit"-button is clicked
submitButtonTextstringUse this to change the text on the "Submit"-button.'Submit'
labelstringUsed to give a label to the input field