{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/5286","labels_url":"https://api.github.com/repos/facebook/react-native/issues/5286/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/5286/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/5286/events","html_url":"https://github.com/facebook/react-native/pull/5286","id":126460928,"number":5286,"title":"Simplified AlertIOS","user":{"login":"corbt","id":176426,"avatar_url":"https://avatars.githubusercontent.com/u/176426?v=3","gravatar_id":"","url":"https://api.github.com/users/corbt","html_url":"https://github.com/corbt","followers_url":"https://api.github.com/users/corbt/followers","following_url":"https://api.github.com/users/corbt/following{/other_user}","gists_url":"https://api.github.com/users/corbt/gists{/gist_id}","starred_url":"https://api.github.com/users/corbt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corbt/subscriptions","organizations_url":"https://api.github.com/users/corbt/orgs","repos_url":"https://api.github.com/users/corbt/repos","events_url":"https://api.github.com/users/corbt/events{/privacy}","received_events_url":"https://api.github.com/users/corbt/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react-native/labels/CLA%20Signed","name":"CLA Signed","color":"e7e7e7"},{"url":"https://api.github.com/repos/facebook/react-native/labels/GH%20Review:%20review-needed","name":"GH Review: review-needed","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-01-13T16:41:46Z","updated_at":"2016-01-18T12:42:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/react-native/pulls/5286","html_url":"https://github.com/facebook/react-native/pull/5286","diff_url":"https://github.com/facebook/react-native/pull/5286.diff","patch_url":"https://github.com/facebook/react-native/pull/5286.patch"},"body":"Ok, so this started as fixing #5273 but ended up getting a little more complicated. :smile: \r\n\r\nCurrently, AlertIOS has the following API:\r\n\r\n* `alert(title, message, buttons, type)`\r\n* `prompt(title, defaultValue, buttons, callback)`\r\n\r\nI've changed the API to look like the following:\r\n\r\n* `alert(title, message, callbackOrButtons)`\r\n* `prompt(title, message, callbackOrButtons, type, defaultValue)`\r\n\r\nI know that breaking changes are a big deal, but I find the current alert API to be fairly inconsistent and unnecessarily confusing. I'll try to justify my changes one by one:\r\n\r\n1. Currently `type` is an optional parameter of `alert`. However, the only reason to change the alert type from the default is in order to create one of the input dialogs (text, password or username/password). So we're in a weird state where if you want a normal text input, you use `prompt`, but if you want a password input you use `alert` with the 'secure-text' type. I've moved `type` to `prompt` so all text input is now done with `prompt`.\r\n2. Currently the only way to fire a callback when a user dismisses an `alert` is by passing in custom buttons. However, `prompt` allows you to pass in a callback that is called when the user clicks the \"OK\" button, without having to define custom buttons. But, you have to pass `null` to either the callback or buttons parameter (can't define both). Since these are mutually exclusive, I've combined them into one parameter and added analogous functionality to both `alert` and the `prompt` to make their APIs more consistent.\r\n3. The defaultValue functionality of `prompt` got broken between 0.16 and 0.17. I've added it back in as an explicit argument (the default value reused the `message` field before, but there are times when you might want both a default value and a message, so they should be separate).\r\n\r\nThose were all the major changes I made. I did also refactor the UIExplorer a bit to make it more clear what's going on in each example, and updated the documentation for AlertIOS."},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/172518207","html_url":"https://github.com/facebook/react-native/pull/5286#issuecomment-172518207","issue_url":"https://api.github.com/repos/facebook/react-native/issues/5286","id":172518207,"user":{"login":"facebook-github-bot","id":6422482,"avatar_url":"https://avatars.githubusercontent.com/u/6422482?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook-github-bot","html_url":"https://github.com/facebook-github-bot","followers_url":"https://api.github.com/users/facebook-github-bot/followers","following_url":"https://api.github.com/users/facebook-github-bot/following{/other_user}","gists_url":"https://api.github.com/users/facebook-github-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook-github-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook-github-bot/subscriptions","organizations_url":"https://api.github.com/users/facebook-github-bot/orgs","repos_url":"https://api.github.com/users/facebook-github-bot/repos","events_url":"https://api.github.com/users/facebook-github-bot/events{/privacy}","received_events_url":"https://api.github.com/users/facebook-github-bot/received_events","type":"User","site_admin":false},"created_at":"2016-01-18T12:42:06Z","updated_at":"2016-01-18T12:42:06Z","body":"@corbt updated the pull request."}}