Refactored component out of container.
This commit is contained in:
parent
5fbecda9f6
commit
c8d37bab15
3 changed files with 34 additions and 16 deletions
|
@ -1,13 +1,16 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { getQueryParamByName } from './utils.js';
|
import { getQueryParamByName } from './utils.js';
|
||||||
import ScoutOverview from './containers/ScoutOverview.js';
|
import ScoutOverviewCont from './containers/ScoutOverview.js';
|
||||||
|
import ScoutOverview from './components/ScoutOverview.js';
|
||||||
|
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
render() {
|
render() {
|
||||||
const scoutID = getQueryParamByName("id", this.props.slug);
|
const scoutID = getQueryParamByName("id", this.props.slug);
|
||||||
|
var MainView = ScoutOverviewCont(ScoutOverview);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<ScoutOverview scoutID={scoutID} />
|
<MainView scoutID={scoutID} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
16
src/components/ScoutOverview.js
Normal file
16
src/components/ScoutOverview.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default ScoutOverview = (
|
||||||
|
{scoutID,
|
||||||
|
displayName,
|
||||||
|
advancementDeadline,
|
||||||
|
completedAdventures,
|
||||||
|
completedAchievements}
|
||||||
|
) => {
|
||||||
|
console.log(data);
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{displayName}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,22 +1,21 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { gql, graphql } from 'react-apollo';
|
import { gql, graphql } from 'react-apollo';
|
||||||
|
|
||||||
function ScoutOverview({data, scoutID}) {
|
|
||||||
console.log(data);
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
{data.getScout && data.getScout.displayName}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default graphql(gql`
|
export default graphql(gql`
|
||||||
query GetScoutData($scoutID:ID!){
|
query GetScoutData($scoutID:ID!){
|
||||||
getScout(id: $scoutID){
|
getScout(id: $scoutID){
|
||||||
displayName
|
displayName,
|
||||||
|
advancementDeadline,
|
||||||
|
adventures,
|
||||||
|
acheivments,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,{options : ({scoutID}) => {
|
`,{
|
||||||
console.log("Building var! scoutId: ", scoutID);
|
options : ({scoutID}) => ({variables: {scoutID}}),
|
||||||
return {variables: {scoutID}};
|
props: ({ ownProps, data }) => {
|
||||||
}})(ScoutOverview);
|
scoutID: ownProps.scoutID,
|
||||||
|
displayName: data.getScout.displayName,
|
||||||
|
completedAdventures: data.getScout.adventures,
|
||||||
|
completedAchievements: data.getScout.achievements,
|
||||||
|
advancementDeadline: data.getScout.advancementDeadline
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue