Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
<div>
{this.props.confirmation}
</div>
<div>
<button> this.props.proceed()}>Yes</button>
<button> this.props.cancel()}>No</button>
</div>
);
}
}
// Adds ReactConfirmProps to CustomModal component
const ConfirmModal = confirmable(CustomModal);
// This is the function you need to call to open your modal, then you can use the
// Promise object it returns to handle "proceed()" or "cancel()" functions.
const confirm = createConfirmation(ConfirmModal);
const markup = (
<div>
<b>Are you sure you want to delete this item?</b>
</div>
);
// This is how you can detect what option ("Yes" or "No") the user has chosen.
confirm({ confirmation: markup })
.then((result) => {
// User chose "Yes"
})
}
}
Confirmation.propTypes = {
okLabbel: PropTypes.string,
cancelLabel: PropTypes.string,
title: PropTypes.string,
confirmation: PropTypes.string,
show: PropTypes.bool,
proceed: PropTypes.func, // called when ok button is clicked.
cancel: PropTypes.func, // called when cancel button is clicked.
dismiss: PropTypes.func, // called when backdrop is clicked or escaped.
enableEscape: PropTypes.bool,
}
export default confirmable(Confirmation);
background-color: ${COLORS.gray.veryLight};
}
`;
const ConfirmButton = styled.button`
${actionButtonCSS};
`;
const CancelButton = styled.button`
${actionButtonCSS};
border-right: 1px solid ${COLORS.gray.light};
`;
Confirm.propTypes = propTypes;
export default confirmable(Confirm);
<div>
<button>确定</button>
<button>取消</button>
)
}
}
export default confirmable(ConfirmModal)</div>
<dialog open="{show}" title="{title}">
{confirmation}
</dialog>
);
}
}
export default confirmable(Confirmation);
<button>Cancel</button>
<button>1st</button>
<button>2nd</button>
<button>3rd</button>
)
}
}
export default confirmable(ComplexConfirmation);