From fffd47f1a95f7b4406a1d63a6b01e9160e918625 Mon Sep 17 00:00:00 2001 From: Amy Slagle Date: Wed, 12 Jul 2017 16:43:01 -0400 Subject: [PATCH] Made library-related header links update when library changes. --- src/components/CatalogHandler.tsx | 4 ++-- src/components/Header.tsx | 13 +++++++------ src/components/__tests__/CatalogHandler-test.tsx | 6 +++--- src/components/__tests__/Header-test.tsx | 4 ++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/components/CatalogHandler.tsx b/src/components/CatalogHandler.tsx index ce66a4477..26c514a4f 100644 --- a/src/components/CatalogHandler.tsx +++ b/src/components/CatalogHandler.tsx @@ -22,13 +22,13 @@ export interface CatalogHandlerProps extends React.Props { export default class CatalogHandler extends React.Component { static childContextTypes: React.ValidationMap = { tab: React.PropTypes.string, - library: React.PropTypes.string + library: React.PropTypes.func }; getChildContext() { return { tab: this.props.params.tab, - library: this.getLibrary(this.props.params.collectionUrl, this.props.params.bookUrl) + library: () => this.getLibrary(this.props.params.collectionUrl, this.props.params.bookUrl) }; } diff --git a/src/components/Header.tsx b/src/components/Header.tsx index cf56ed56b..57046e078 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -17,10 +17,10 @@ export interface HeaderProps extends React.Props
{ } export class Header extends React.Component { - context: { library: string, router: Router }; + context: { library: () => string, router: Router }; static contextTypes = { - library: React.PropTypes.string, + library: React.PropTypes.func, router: React.PropTypes.object.isRequired }; @@ -40,7 +40,7 @@ export class Header extends React.Component { { !this.context.library && @@ -60,21 +60,21 @@ export class Header extends React.Component {