-
Notifications
You must be signed in to change notification settings - Fork 14
Building off of my other PR: Passing error to children #9
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Client side Renders child component with context dependencies 1`] = `"<div>No errors! Context variable</div>"`; | ||
|
||
exports[`Client side Renders child component with legacy context dependencies 1`] = `"<div>No errors! Context variable</div>"`; | ||
|
||
exports[`Client side Renders child component with multiple contexts dependencies 1`] = `"<div>No errors! Context variable1 Context variable2 Context variable3</div>"`; | ||
|
||
exports[`Client side Renders child component without errors 1`] = `"<div>No errors!</div>"`; | ||
|
||
exports[`Client side Renders fallBack component if children rendering throws error 1`] = `"<div>FallBack!</div>"`; | ||
|
||
exports[`Client side Renders fallBack component if children rendering throws error with contexts 1`] = `"<div>FallBack!</div>"`; | ||
|
||
exports[`Client side Renders nothing when children rendering throws error and no fallBack provided 1`] = `null`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Server side Renders child component with context dependencies 1`] = `"<div><div>No errors! Context variable</div></div>"`; | ||
|
||
exports[`Server side Renders child component with multiple new context dependencies 1`] = `"<div><div>No errors! Context variable1 Context variable2 Context variable3</div></div>"`; | ||
|
||
exports[`Server side Renders child component without errors 1`] = `"<div><div>No errors!</div></div>"`; | ||
|
||
exports[`Server side Renders fallBack component if children rendering throws error 1`] = `"<div>FallBack!</div>"`; | ||
|
||
exports[`Server side Renders fallBack component if children rendering throws error with new contexts 1`] = `"<div>FallBack!</div>"`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ export function _render (self, ProvideContext) { | |
const __html = renderToStaticMarkup(elementWithProviders) | ||
return <div dangerouslySetInnerHTML={{__html}} /> | ||
} catch (e) { | ||
return <div>{self.props.fallBack()}</div> | ||
return <>{self.props.fallBack()}</> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, the Fragmet syntax is excess here:) fallBack'll return some jsx elements already There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the server's fallback gets an exception's error in arguments, it would be cool too;)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to be a problem when React tries to hydrate the DOM. If the DOM structure doesn't match what would normally be rendered, then it can result in zombie elements which do not get re-rendered. The fallback content isn't going to be the same as whatever we expected to render, but removing that div even with no fallback will be something that hydrate handles badly. |
||
} | ||
}) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can write conditions after "else" without "else". Possible, it'll be read better that way;)