React: How to send data on Popup close?

Active3 hr before
Viewed126 times

10 Answers


Stack Overflow help chat , Meta Stack Overflow ,Stack Overflow en español

on child

handleListSubmit = () => {


Creating a React Bootstrap Modal,The below line of code shows how you can pass your own callback function as props to React Bootstrap's modal component:,Using any of the above methods,. you get a full page to reload and an alert as the validation on closing the modal.

1n pm install react - bootstrap bootstrap
load more v

Modal: A wrapper containing other section components explained below.,Modal.Header: The header section of the modal having Close (Icon) and Title text.,Modal.Footer: The bottom section of the modal having action buttons like Close, Submit added in the footer section.

import 'bootstrap/dist/css/bootstrap.min.css';

 Pretag team - issue, fix, solve, resolve

Firstly, let's pass data between a parent component and a child component. .,First, you'll need to create two components, one parent and one child.,Now, you can pass data from Child to Parent and Parent to Child like a pro.

import React from 'react'

export default function Parent() {
  return (
load more v

Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.,Normally, when you return an element from a component’s render method, it’s mounted into the DOM as a child of the nearest parent node:,A typical use case for portals is when a parent component has an overflow: hidden or z-index style, but you need the child to visually “break out” of its container. For example, dialogs, hovercards, and tooltips.

ReactDOM.createPortal(child, container)
load more v

The dialog has a close button added to aide usability.,You can create a draggable dialog by using react-draggable. To do so, you can pass the the imported Draggable component as the PaperComponent of the Dialog component. This will make the entire dialog draggable.,Here is an example of customizing the component. You can learn more about this in the overrides documentation page.

<Typography variant="subtitle1">Selected: {selectedValue}</Typography>
<br />
<Button variant="outlined" color="primary" onClick={handleClickOpen}>
  Open simple dialog
<SimpleDialog selectedValue={selectedValue} open={open} onClose={handleClose} />
load more v

The Modal component receives a lot of props. onSubmit for form submit action, modalRef to refer modal area and buttonRef to refer close button. closeModal, showModal to close and show the modal. It also gets onClickOutside so that we can detect the user click outside the Modal and close modal.,closeButton is the buttonRef passed in the Modal component.,I also passed onSubmit function for the form submit action from App component.

 Pretag team - issue, fix, solve, resolve

State: While props allow you to pass data from a parent component to a child component, the state is used to change the component, well, state from within. Changes to the state also trigger a UI update.,Props: It allows you to pass data from a parent component to a child component.,The props and state are the main concepts of React. Actually, only changes in props and/ or state trigger React to rerender your components and potentially update the DOM in the browser


To show or hide the Popup programmatically, call the show() or hide() method. The same thing can be done using the toggle(showing) method. Pass true or false to this method to show or hide the Popup, respectively.,With Angular, Vue or React, use a different technique. Bind the visible property of the Popup UI component to a component property. After that, change this component property, and the Popup will appear or disappear.,Handle Events: Angular | Vue | React | jQuery | AngularJS | Knockout

$(function() {
        title: "Popup Title",
        contentTemplate: function () {
            return $("<p />").text("Popup content");
        text: "Show the Popup", 
        onClick: function () {
            // === or ===
            $("#popupContainer").dxPopup("toggle", true);
        text: "Hide the Popup", 
        onClick: function () {
            // === or ===
            $("#popupContainer").dxPopup("toggle", false);
load more v

Other "react-undefined" queries related to "React: How to send data on Popup close?"