Closed SkyJedi closed 7 years ago
May I ask what you need it for? Or rather how you would use it so I can get an idea of it.
simply I'd like to have a popup ask for confirmation on deleting data.
click a button---->popup "are you sure"---->do this function that involves setting state
Something like this?
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
foo: 'bar'
};
}
confirm() {
Popup.create({
title: 'Are you sure?',
content: 'Everything will be lost forever',
buttons: {
left: ['cancel'],
right: [{
text: 'Yes!',
action: () => {
this.setState({foo: 'baz'});
}
}]
}
});
}
render() {
return <button onClick={() => this.confirm()}>Click me</button>;
}
}
HOLY CRAP YES!
sorry, I'm not good at this
@tbleckert - I was performing the same logic as you with no success.
My solution was, after looking close at your code, changing the action
to take () => ..
instead of function ()
.
Would you have any insight into why the latter worked (unless this feels like a mystery case).
Would love to understand more about why that changed actually worked.
Is it possible to pass a variable to and from the popup. I've found a work around by setting a firebase varaible within the popup, but it would be super helpful to pass a variable