withAccount.js 618 B
Newer Older
Axel Chalon's avatar
Axel Chalon committed
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause

import { withRouter } from 'react-router-dom';
Axel Chalon's avatar
Axel Chalon committed

const AccountAddressFromRouter = withRouter(props =>
  props.children(props.match.params.accountAddress)

// We don't want to pass the router props to the returned component
export default Component => initialProps => {
  return (
    <AccountAddressFromRouter>
      {accountAddress => (
        <Component accountAddress={accountAddress} {...initialProps} />
      )}
    </AccountAddressFromRouter>
  );
};