Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
fix: don't ignore descriptors change
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Oct 15, 2019
1 parent 0a5fb3e commit 9d9fe31
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/stack/src/views/Stack/StackView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type State = {
routes: Route<string>[];
// Previous routes, to compare whether routes have changed or not
previousRoutes: Route<string>[];
// Previous descriptors, to compare whether descriptors have changed or not
previousDescriptors: StackDescriptorMap;
// List of routes being opened, we need to animate pushing of these new routes
openingRouteKeys: string[];
// List of routes being closed, we need to animate popping of these routes
Expand All @@ -50,6 +52,23 @@ class StackView extends React.Component<Props, State> {
) {
// If there was no change in routes, we don't need to compute anything
if (props.state.routes === state.previousRoutes && state.routes.length) {
if (props.descriptors !== state.previousDescriptors) {
const descriptors = state.routes.reduce(
(acc, route) => {
acc[route.key] =
props.descriptors[route.key] || state.descriptors[route.key];

return acc;
},
{} as StackDescriptorMap
);

return {
previousDescriptors: props.descriptors,
descriptors,
};
}

return null;
}

Expand Down Expand Up @@ -189,6 +208,7 @@ class StackView extends React.Component<Props, State> {
return {
routes,
previousRoutes: props.state.routes,
previousDescriptors: props.descriptors,
openingRouteKeys,
closingRouteKeys,
replacingRouteKeys,
Expand All @@ -199,6 +219,7 @@ class StackView extends React.Component<Props, State> {
state: State = {
routes: [],
previousRoutes: [],
previousDescriptors: {},
openingRouteKeys: [],
closingRouteKeys: [],
replacingRouteKeys: [],
Expand Down

0 comments on commit 9d9fe31

Please sign in to comment.