{"action":"created","issue":{"url":"https://api.github.com/repos/romac/react-if/issues/4","labels_url":"https://api.github.com/repos/romac/react-if/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/romac/react-if/issues/4/comments","events_url":"https://api.github.com/repos/romac/react-if/issues/4/events","html_url":"https://github.com/romac/react-if/issues/4","id":104302084,"number":4,"title":"Add support for lazy evaluation of children","user":{"login":"romac","id":106849,"avatar_url":"https://avatars.githubusercontent.com/u/106849?v=3","gravatar_id":"","url":"https://api.github.com/users/romac","html_url":"https://github.com/romac","followers_url":"https://api.github.com/users/romac/followers","following_url":"https://api.github.com/users/romac/following{/other_user}","gists_url":"https://api.github.com/users/romac/gists{/gist_id}","starred_url":"https://api.github.com/users/romac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romac/subscriptions","organizations_url":"https://api.github.com/users/romac/orgs","repos_url":"https://api.github.com/users/romac/repos","events_url":"https://api.github.com/users/romac/events{/privacy}","received_events_url":"https://api.github.com/users/romac/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-01T16:15:12Z","updated_at":"2016-01-17T22:07:54Z","closed_at":"2016-01-17T22:07:54Z","body":"**Motivation:** Children of both the `Then` and `Else` branch are currently being eagerly evaluated regardless of which branch will eventually be rendered. See issue #1 for more details.\r\n\r\nThe idea suggested by @tlrobinson is to wrap children of both branches in an anonymous function that will be called only if the branch is to be rendered based on the condition:\r\n\r\n```jsx\r\n<If condition={cond}>\r\n    <Then>{() => <Foo />}</Then>\r\n    <Else>{() => <Bar />}</Else>\r\n</If>\r\n```\r\n\r\nWe might also want to support both styles (with or without the function), to lighten the syntax a bit when there is eg. no performance concern:\r\n\r\n```jsx\r\n<If condition={cond}>\r\n    <Then>{() => <BigComponent />}</Then>\r\n    <Else>That was quick!</Else>\r\n</If>\r\n```"},"comment":{"url":"https://api.github.com/repos/romac/react-if/issues/comments/172388508","html_url":"https://github.com/romac/react-if/issues/4#issuecomment-172388508","issue_url":"https://api.github.com/repos/romac/react-if/issues/4","id":172388508,"user":{"login":"romac","id":106849,"avatar_url":"https://avatars.githubusercontent.com/u/106849?v=3","gravatar_id":"","url":"https://api.github.com/users/romac","html_url":"https://github.com/romac","followers_url":"https://api.github.com/users/romac/followers","following_url":"https://api.github.com/users/romac/following{/other_user}","gists_url":"https://api.github.com/users/romac/gists{/gist_id}","starred_url":"https://api.github.com/users/romac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romac/subscriptions","organizations_url":"https://api.github.com/users/romac/orgs","repos_url":"https://api.github.com/users/romac/repos","events_url":"https://api.github.com/users/romac/events{/privacy}","received_events_url":"https://api.github.com/users/romac/received_events","type":"User","site_admin":false},"created_at":"2016-01-17T22:07:54Z","updated_at":"2016-01-17T22:07:54Z","body":"Fixed by #5."}}