Skip to content

Instantly share code, notes, and snippets.

@testshallpass
Created October 4, 2018 02:03
Show Gist options
  • Save testshallpass/d76c656874e417bef4e0e6a63fc492af to your computer and use it in GitHub Desktop.
Save testshallpass/d76c656874e417bef4e0e6a63fc492af to your computer and use it in GitHub Desktop.
DropdownHolder Example #1
export class App extends React.Component {
render() {
return (
<View style={{width: '100%', height: '100%'}}>
<Nav/>
<DropdownAlert ref={(ref) => DropDownHolder.setDropDown(ref)}/>
</View>
)
}
}
// ...
export class DropDownHolder {
static dropDown;
static setDropDown(dropDown) {
this.dropDown = dropDown;
}
static getDropDown() {
return this.dropDown;
}
}
@JayGajjar
Copy link

Usage :

DropDownHolder.dropDown.alertWithType('error', 'Error', 'Error message');

@AhmadJawabra
Copy link

be sure to create separate component that contain DropDownHolder to write clean code

@cyb3rsalih
Copy link

should we have a connect()(Screen) like linker for screens also, like redux

@appsgenie
Copy link

is there a way to close actively open alert when another one is requested to show?
I am trying to see how this would play out with a lot of incoming alerts. I think on iOS the main notifications alert shows for a min amount of time then quickly closes to show the next one that's queued up.. Currently , the DropdownAlert here has to allow the interval to pass before showing the next one..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment