{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/9468","repository_url":"https://api.github.com/repos/facebook/react","labels_url":"https://api.github.com/repos/facebook/react/issues/9468/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/9468/comments","events_url":"https://api.github.com/repos/facebook/react/issues/9468/events","html_url":"https://github.com/facebook/react/issues/9468","id":223122848,"number":9468,"title":"How to render object with custom toString?","user":{"login":"cwtuan","id":3455798,"avatar_url":"https://avatars3.githubusercontent.com/u/3455798?v=3","gravatar_id":"","url":"https://api.github.com/users/cwtuan","html_url":"https://github.com/cwtuan","followers_url":"https://api.github.com/users/cwtuan/followers","following_url":"https://api.github.com/users/cwtuan/following{/other_user}","gists_url":"https://api.github.com/users/cwtuan/gists{/gist_id}","starred_url":"https://api.github.com/users/cwtuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cwtuan/subscriptions","organizations_url":"https://api.github.com/users/cwtuan/orgs","repos_url":"https://api.github.com/users/cwtuan/repos","events_url":"https://api.github.com/users/cwtuan/events{/privacy}","received_events_url":"https://api.github.com/users/cwtuan/received_events","type":"User","site_admin":false},"labels":[{"id":40929155,"url":"https://api.github.com/repos/facebook/react/labels/Type:%20Question","name":"Type: Question","color":"cc317c","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2017-04-20T16:19:10Z","updated_at":"2017-04-20T17:40:11Z","closed_at":"2017-04-20T16:30:07Z","body":"I'm implementing a i18n library, and would like to render a object with custom toString like this:\r\n\r\n```\r\nconst i18nObject = {\r\n  toString() {\r\n    return 'xxx';\r\n  }\r\n};\r\n```\r\n\r\n```\r\nrender() {\r\n  return {i18nObject}\r\n}\r\n```\r\n\r\nBut got the error:\r\n\r\ninvariant.js:44 Uncaught Error: Objects are not valid as a React child (found: xxx). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of `App`. at invariant (invariant.js:44)\r\n\r\nDoes anyone know if there's any method to do this?"},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/295828440","html_url":"https://github.com/facebook/react/issues/9468#issuecomment-295828440","issue_url":"https://api.github.com/repos/facebook/react/issues/9468","id":295828440,"user":{"login":"bvaughn","id":29597,"avatar_url":"https://avatars3.githubusercontent.com/u/29597?v=3","gravatar_id":"","url":"https://api.github.com/users/bvaughn","html_url":"https://github.com/bvaughn","followers_url":"https://api.github.com/users/bvaughn/followers","following_url":"https://api.github.com/users/bvaughn/following{/other_user}","gists_url":"https://api.github.com/users/bvaughn/gists{/gist_id}","starred_url":"https://api.github.com/users/bvaughn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bvaughn/subscriptions","organizations_url":"https://api.github.com/users/bvaughn/orgs","repos_url":"https://api.github.com/users/bvaughn/repos","events_url":"https://api.github.com/users/bvaughn/events{/privacy}","received_events_url":"https://api.github.com/users/bvaughn/received_events","type":"User","site_admin":false},"created_at":"2017-04-20T17:40:11Z","updated_at":"2017-04-20T17:40:11Z","body":"`<div>Hi, {i18n(object)}</div>` works okay in my above example b'c `i18n` returns a string (not an object).\r\n\r\n> `toString` will be implicitly called when you try to concat the object with string.\r\n\r\nYes, this is true. But React doesn't concatenate with a string- except for when displaying the invariant error heh. See [here](https://github.com/facebook/react/blob/master/src/isomorphic/children/traverseAllChildren.js#L146-L163)."}}
{"actor":{"display_login":"bvaughn"}}