Skip to content

Commit

Permalink
Use createMatchSelector selector in RecoverWithLink component (#1966)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinbodnar committed Oct 19, 2021
1 parent 2f2066f commit 884993c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/frontend/src/components/accounts/RecoverWithLink.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createMatchSelector } from 'connected-react-router';
import React, { Component } from 'react';
import { Translate } from 'react-localize-redux';
import { connect } from 'react-redux';
Expand Down Expand Up @@ -167,7 +168,7 @@ class RecoverWithLink extends Component {
handleContinue = async () => {
await Mixpanel.withTracking("IE Recover with link",
async () => {
await this.props.recoverAccountSeedPhrase(this.state.seedPhrase, this.props.match.params.accountId, false);
await this.props.recoverAccountSeedPhrase(this.state.seedPhrase, this.props.accountId, false);
this.props.refreshAccount();
this.props.redirectTo('/');
this.props.clearAccountState();
Expand Down Expand Up @@ -245,12 +246,16 @@ const mapDispatchToProps = {
clearAccountState
};

const mapStateToProps = (state, { match }) => ({
...selectAccountSlice(state),
accountId: match.params.accountId,
seedPhrase: match.params.seedPhrase,
mainLoader: selectStatusMainLoader(state)
});
const mapStateToProps = (state) => {
const matchSelector = createMatchSelector('/recover-with-link/:accountId/:seedPhrase');

return {
...selectAccountSlice(state),
accountId: matchSelector(state)?.params.accountId,
seedPhrase: matchSelector(state)?.params.seedPhrase,
mainLoader: selectStatusMainLoader(state)
};
};

export const RecoverWithLinkWithRouter = connect(
mapStateToProps,
Expand Down

0 comments on commit 884993c

Please sign in to comment.