-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate router and <app-view> to React #4525
Changes from 6 commits
ee529fe
94e3de1
0e85dd8
ce64f0d
4058093
b4ff41c
d874669
8bb6c6d
e4350f0
933b50a
d2e0f98
824ef59
b2b504e
9815996
7306d21
b140b55
e075d40
4f299fe
0336dad
79111f2
5c94b70
ebaf1e2
09c096c
5b7d56c
f77f602
efeecb6
6e6c1df
d2e0beb
d4a769b
dea46de
dc4051a
a54d917
d822d39
a92d1fa
2755e12
f8e7334
7e3f9cf
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 |
---|---|---|
|
@@ -412,10 +412,10 @@ DashboardPage.defaultProps = { | |
|
||
export default { | ||
path: "/dashboard/:dashboardSlug", | ||
render: routeParams => ( | ||
<AuthenticatedPageWrapper key={`/dashboard/${routeParams.dashboardSlug}`}> | ||
render: currentRoute => ( | ||
<AuthenticatedPageWrapper key={currentRoute.key}> | ||
<ErrorBoundaryContext.Consumer> | ||
{({ handleError }) => <DashboardPage {...routeParams} onError={handleError} />} | ||
{({ handleError }) => <DashboardPage {...currentRoute.routeParams} onError={handleError} />} | ||
</ErrorBoundaryContext.Consumer> | ||
</AuthenticatedPageWrapper> | ||
), | ||
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. Not sure if it's that worth it at this point, but it looks like pages follow the same pattern when being defined, if this is not intended to be changed (and every page should follow this notation), we perhaps could abstract it a bit more with a closure returning this function? (seems we can tweak it to receive only the page component and some extra routeParams): {
path: "/dashboard/:dashboardSlug",
render: authenticatedPage(DashboardPage, { extraData: "dashboard-page" }),
} BTW, if I had to choose, I think it's better to pass Well, lmk your opinion 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.
|
||
|
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.
Why do we need to duplicate this piece of logic (AuthenticatedPage + ErrorBoundry) on every page?
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.
Also, passing
handleError
to every page feels like too much. Can't we solve this with some global state/context?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.
As I mentioned in reply to @gabrieldutra, I'm going to revisit this and few other things in a follow-up PR; currently it's stable, and I prefer not to add any more changes to this PR.
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.
Yes, and that's what I plan to do. There is a context already though; it's easy to use it with function-based components and a bit trickier with class-based ones - I didn't want to deal with it now so just passed it as a prop everywhere.