Skip to content

Commit

Permalink
Consumerize ContextPane
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Apr 30, 2019
1 parent aecec3b commit 3a8ee66
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Farmhand.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ export default class Farmhand extends Component {
<NotificationSystem ref={notificationSystemRef} />
<div className="sidebar">
<Navigation />
<ContextPane {...{ handlers, state }} />
<ContextPane />
<DebugMenu {...{ handlers, state }} />
</div>
<Stage {...{ handlers, state }} />
Expand Down
11 changes: 9 additions & 2 deletions src/components/ContextPane/ContextPane.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import FarmhandContext from '../../Farmhand.context';
import { object, shape, string } from 'prop-types';
import Toolbelt from '../Toolbelt';
import PlantableItems from '../PlantableItems';
Expand All @@ -9,7 +10,7 @@ import './ContextPane.sass';

// TODO: Render player inventory for stageFocus === SHOP.

const ContextPane = ({ handlers, state, state: { stageFocus } }) => (
export const ContextPane = ({ handlers, state, state: { stageFocus } }) => (
<div className="ContextPane">
{stageFocus === stageFocusType.FIELD && (
<>
Expand Down Expand Up @@ -37,4 +38,10 @@ ContextPane.propTypes = {
}).isRequired,
};

export default ContextPane;
export default function Consumer() {
return (
<FarmhandContext.Consumer>
{context => <ContextPane {...context} />}
</FarmhandContext.Consumer>
);
}
2 changes: 1 addition & 1 deletion src/components/ContextPane/ContextPane.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import ContextPane from './ContextPane';
import { ContextPane } from './ContextPane';
import { stageFocusType } from '../../../src/enums';
import PlantableItems from '../PlantableItems';
import { shallow } from 'enzyme';
Expand Down

0 comments on commit 3a8ee66

Please sign in to comment.