How to solve 'TypeError: Cannot read property 'params' of undefined' with Apollo Graphql Client and React?












0















I'm trying to connect a deck URL to link to the cards list, similar to how I see it was done on Traversy's SpaceX graphql demo. I'm receiving the error TypeError: Cannot read property 'params' of undefined when clicking a link to either of the demo decks.



This is a React client I have built on top of the server, using Apollo with GraphQL connected to my functional PostgreSQL DB. I've pinpointed the issue to what appears to be these lines, and how the props are being passed through React and Apollo. Do note I am a beginner with GraphQL and Apollo, and this is my first real project with React, so any guidance to understanding the process would be appreciated.



let { id } = this.props.match.params;
id = parseInt(id);


Decks index.js



    import React, { Component, Fragment } from "react";
import gql from "graphql-tag";
import { Query } from "react-apollo";

import Loading from "../../Loading";
import DeckItem from "./DeckItem";

const GET_DECKS = gql`
query DeckQuery {
decks @connection(key: "DeckConnection") {
edges {
id
deckName
createdAt
cards {
id
front
}
}
}
}
`;

class Decks extends Component {
render() {
return (
<Fragment>
<h1>Deck</h1>
<Query query={GET_DECKS}>
{({ data, error, loading }) => {
if (loading) {
return <Loading />;
}
if (error) {
return <p>Error</p>;
}

const decksToRender = data.decks.edges;

return (
<Fragment>
{console.log(data)}
{decksToRender.map(deck => (
<DeckItem key={deck.id} deck={deck} />
))}
</Fragment>
);
}}
</Query>
</Fragment>
);
}
}

export default Decks;


DeckItem index.js



    import React from "react";
import Moment from "react-moment";
import { Link } from "react-router-dom";

export default function DeckItem({ deck: { id, deckName, createdAt } }) {
return (
<div>
<div>
<h2>
<Link to={`/deck/${id}`}>{deckName}</Link>
</h2>
<p>Description coming soon...</p>
<h5>
Created on <Moment format="YYYY-MM-DD HH:mm">{createdAt}</Moment>
</h5>
</div>
</div>
);
}


Cards index.js



    import React, { Component, Fragment } from "react";
import gql from "graphql-tag";
import { Query } from "react-apollo";
import { Link } from "react-router-dom";

import Loading from "../../../Loading";

const CARDS_QUERY = gql`
query CardsQuery($id: ID!) {
deck(id: $id) {
id
deckName
cards {
id
front
back
}
}
}
`;

export class Cards extends Component {
render() {
let { id } = this.props.match.params;
id = parseInt(id);
return (
<Fragment>
<Query query={CARDS_QUERY} variables={{ id }}>
{({ data, error, loading }) => {
if (loading) {
return <Loading />;
}
if (error) {
return <p>Error</p>;
}
const {
id,
card: { front, back }
} = data.deck;
return (
<div>
<ul>
<h1>
<li>
<span>Id:</span> {id}
</li>
</h1>
<h4>Details</h4>
<li>Front: {front}</li>
<li>Back: {back}</li>
</ul>
<hr />
<Link to="/">Back</Link>
</div>
);
}}
</Query>
</Fragment>
);
}
}

export default Cards;


Relevant React router routes



    ```
import { Router, Route } from "react-router-dom";
```
import FlashCardPage from "../FlashCards";
import Cards from "../FlashCards/Cards/CardsItem";

import * as routes from "../../constants/routes";

<Router>
```
<Route
exact
path={routes.FLASHCARDS}
component={() => <FlashCardPage />}
/>
<Route exact path={routes.CARDS} component={() => <Cards />} />
</div>
</Router>


the path in my routes file is "/deck/:id"



Console Error log



            react-dom.development.js:19782 Uncaught TypeError: Cannot read property 'params' of undefined
at Cards.render (index.js:23)

index.js:1452 The above error occurred in the <Cards> component:
in Cards (at App/index.js:42)
in component (created by Route)
in Route (at App/index.js:42)
in div (at App/index.js:19)
in Router (at App/index.js:18)
in App (at withSession.js:8)
in Query (at withSession.js:6)
in Unknown (at src/index.js:84)
in ApolloProvider (at src/index.js:83)


The result should be a deck showing a list of the cards, '/deck/1' should show 2 or 3 cards from my PostgreSQL server. Currently I can only see the decks with a url, but upon clicking, it throws up the error immediately. Other Graphql functions are working correctly, and using Playground the query works just fine, so it seems I'm not passing props correctly. Any additional information needed, I'll be happy to provide. Thank you!










share|improve this question





























    0















    I'm trying to connect a deck URL to link to the cards list, similar to how I see it was done on Traversy's SpaceX graphql demo. I'm receiving the error TypeError: Cannot read property 'params' of undefined when clicking a link to either of the demo decks.



    This is a React client I have built on top of the server, using Apollo with GraphQL connected to my functional PostgreSQL DB. I've pinpointed the issue to what appears to be these lines, and how the props are being passed through React and Apollo. Do note I am a beginner with GraphQL and Apollo, and this is my first real project with React, so any guidance to understanding the process would be appreciated.



    let { id } = this.props.match.params;
    id = parseInt(id);


    Decks index.js



        import React, { Component, Fragment } from "react";
    import gql from "graphql-tag";
    import { Query } from "react-apollo";

    import Loading from "../../Loading";
    import DeckItem from "./DeckItem";

    const GET_DECKS = gql`
    query DeckQuery {
    decks @connection(key: "DeckConnection") {
    edges {
    id
    deckName
    createdAt
    cards {
    id
    front
    }
    }
    }
    }
    `;

    class Decks extends Component {
    render() {
    return (
    <Fragment>
    <h1>Deck</h1>
    <Query query={GET_DECKS}>
    {({ data, error, loading }) => {
    if (loading) {
    return <Loading />;
    }
    if (error) {
    return <p>Error</p>;
    }

    const decksToRender = data.decks.edges;

    return (
    <Fragment>
    {console.log(data)}
    {decksToRender.map(deck => (
    <DeckItem key={deck.id} deck={deck} />
    ))}
    </Fragment>
    );
    }}
    </Query>
    </Fragment>
    );
    }
    }

    export default Decks;


    DeckItem index.js



        import React from "react";
    import Moment from "react-moment";
    import { Link } from "react-router-dom";

    export default function DeckItem({ deck: { id, deckName, createdAt } }) {
    return (
    <div>
    <div>
    <h2>
    <Link to={`/deck/${id}`}>{deckName}</Link>
    </h2>
    <p>Description coming soon...</p>
    <h5>
    Created on <Moment format="YYYY-MM-DD HH:mm">{createdAt}</Moment>
    </h5>
    </div>
    </div>
    );
    }


    Cards index.js



        import React, { Component, Fragment } from "react";
    import gql from "graphql-tag";
    import { Query } from "react-apollo";
    import { Link } from "react-router-dom";

    import Loading from "../../../Loading";

    const CARDS_QUERY = gql`
    query CardsQuery($id: ID!) {
    deck(id: $id) {
    id
    deckName
    cards {
    id
    front
    back
    }
    }
    }
    `;

    export class Cards extends Component {
    render() {
    let { id } = this.props.match.params;
    id = parseInt(id);
    return (
    <Fragment>
    <Query query={CARDS_QUERY} variables={{ id }}>
    {({ data, error, loading }) => {
    if (loading) {
    return <Loading />;
    }
    if (error) {
    return <p>Error</p>;
    }
    const {
    id,
    card: { front, back }
    } = data.deck;
    return (
    <div>
    <ul>
    <h1>
    <li>
    <span>Id:</span> {id}
    </li>
    </h1>
    <h4>Details</h4>
    <li>Front: {front}</li>
    <li>Back: {back}</li>
    </ul>
    <hr />
    <Link to="/">Back</Link>
    </div>
    );
    }}
    </Query>
    </Fragment>
    );
    }
    }

    export default Cards;


    Relevant React router routes



        ```
    import { Router, Route } from "react-router-dom";
    ```
    import FlashCardPage from "../FlashCards";
    import Cards from "../FlashCards/Cards/CardsItem";

    import * as routes from "../../constants/routes";

    <Router>
    ```
    <Route
    exact
    path={routes.FLASHCARDS}
    component={() => <FlashCardPage />}
    />
    <Route exact path={routes.CARDS} component={() => <Cards />} />
    </div>
    </Router>


    the path in my routes file is "/deck/:id"



    Console Error log



                react-dom.development.js:19782 Uncaught TypeError: Cannot read property 'params' of undefined
    at Cards.render (index.js:23)

    index.js:1452 The above error occurred in the <Cards> component:
    in Cards (at App/index.js:42)
    in component (created by Route)
    in Route (at App/index.js:42)
    in div (at App/index.js:19)
    in Router (at App/index.js:18)
    in App (at withSession.js:8)
    in Query (at withSession.js:6)
    in Unknown (at src/index.js:84)
    in ApolloProvider (at src/index.js:83)


    The result should be a deck showing a list of the cards, '/deck/1' should show 2 or 3 cards from my PostgreSQL server. Currently I can only see the decks with a url, but upon clicking, it throws up the error immediately. Other Graphql functions are working correctly, and using Playground the query works just fine, so it seems I'm not passing props correctly. Any additional information needed, I'll be happy to provide. Thank you!










    share|improve this question



























      0












      0








      0








      I'm trying to connect a deck URL to link to the cards list, similar to how I see it was done on Traversy's SpaceX graphql demo. I'm receiving the error TypeError: Cannot read property 'params' of undefined when clicking a link to either of the demo decks.



      This is a React client I have built on top of the server, using Apollo with GraphQL connected to my functional PostgreSQL DB. I've pinpointed the issue to what appears to be these lines, and how the props are being passed through React and Apollo. Do note I am a beginner with GraphQL and Apollo, and this is my first real project with React, so any guidance to understanding the process would be appreciated.



      let { id } = this.props.match.params;
      id = parseInt(id);


      Decks index.js



          import React, { Component, Fragment } from "react";
      import gql from "graphql-tag";
      import { Query } from "react-apollo";

      import Loading from "../../Loading";
      import DeckItem from "./DeckItem";

      const GET_DECKS = gql`
      query DeckQuery {
      decks @connection(key: "DeckConnection") {
      edges {
      id
      deckName
      createdAt
      cards {
      id
      front
      }
      }
      }
      }
      `;

      class Decks extends Component {
      render() {
      return (
      <Fragment>
      <h1>Deck</h1>
      <Query query={GET_DECKS}>
      {({ data, error, loading }) => {
      if (loading) {
      return <Loading />;
      }
      if (error) {
      return <p>Error</p>;
      }

      const decksToRender = data.decks.edges;

      return (
      <Fragment>
      {console.log(data)}
      {decksToRender.map(deck => (
      <DeckItem key={deck.id} deck={deck} />
      ))}
      </Fragment>
      );
      }}
      </Query>
      </Fragment>
      );
      }
      }

      export default Decks;


      DeckItem index.js



          import React from "react";
      import Moment from "react-moment";
      import { Link } from "react-router-dom";

      export default function DeckItem({ deck: { id, deckName, createdAt } }) {
      return (
      <div>
      <div>
      <h2>
      <Link to={`/deck/${id}`}>{deckName}</Link>
      </h2>
      <p>Description coming soon...</p>
      <h5>
      Created on <Moment format="YYYY-MM-DD HH:mm">{createdAt}</Moment>
      </h5>
      </div>
      </div>
      );
      }


      Cards index.js



          import React, { Component, Fragment } from "react";
      import gql from "graphql-tag";
      import { Query } from "react-apollo";
      import { Link } from "react-router-dom";

      import Loading from "../../../Loading";

      const CARDS_QUERY = gql`
      query CardsQuery($id: ID!) {
      deck(id: $id) {
      id
      deckName
      cards {
      id
      front
      back
      }
      }
      }
      `;

      export class Cards extends Component {
      render() {
      let { id } = this.props.match.params;
      id = parseInt(id);
      return (
      <Fragment>
      <Query query={CARDS_QUERY} variables={{ id }}>
      {({ data, error, loading }) => {
      if (loading) {
      return <Loading />;
      }
      if (error) {
      return <p>Error</p>;
      }
      const {
      id,
      card: { front, back }
      } = data.deck;
      return (
      <div>
      <ul>
      <h1>
      <li>
      <span>Id:</span> {id}
      </li>
      </h1>
      <h4>Details</h4>
      <li>Front: {front}</li>
      <li>Back: {back}</li>
      </ul>
      <hr />
      <Link to="/">Back</Link>
      </div>
      );
      }}
      </Query>
      </Fragment>
      );
      }
      }

      export default Cards;


      Relevant React router routes



          ```
      import { Router, Route } from "react-router-dom";
      ```
      import FlashCardPage from "../FlashCards";
      import Cards from "../FlashCards/Cards/CardsItem";

      import * as routes from "../../constants/routes";

      <Router>
      ```
      <Route
      exact
      path={routes.FLASHCARDS}
      component={() => <FlashCardPage />}
      />
      <Route exact path={routes.CARDS} component={() => <Cards />} />
      </div>
      </Router>


      the path in my routes file is "/deck/:id"



      Console Error log



                  react-dom.development.js:19782 Uncaught TypeError: Cannot read property 'params' of undefined
      at Cards.render (index.js:23)

      index.js:1452 The above error occurred in the <Cards> component:
      in Cards (at App/index.js:42)
      in component (created by Route)
      in Route (at App/index.js:42)
      in div (at App/index.js:19)
      in Router (at App/index.js:18)
      in App (at withSession.js:8)
      in Query (at withSession.js:6)
      in Unknown (at src/index.js:84)
      in ApolloProvider (at src/index.js:83)


      The result should be a deck showing a list of the cards, '/deck/1' should show 2 or 3 cards from my PostgreSQL server. Currently I can only see the decks with a url, but upon clicking, it throws up the error immediately. Other Graphql functions are working correctly, and using Playground the query works just fine, so it seems I'm not passing props correctly. Any additional information needed, I'll be happy to provide. Thank you!










      share|improve this question
















      I'm trying to connect a deck URL to link to the cards list, similar to how I see it was done on Traversy's SpaceX graphql demo. I'm receiving the error TypeError: Cannot read property 'params' of undefined when clicking a link to either of the demo decks.



      This is a React client I have built on top of the server, using Apollo with GraphQL connected to my functional PostgreSQL DB. I've pinpointed the issue to what appears to be these lines, and how the props are being passed through React and Apollo. Do note I am a beginner with GraphQL and Apollo, and this is my first real project with React, so any guidance to understanding the process would be appreciated.



      let { id } = this.props.match.params;
      id = parseInt(id);


      Decks index.js



          import React, { Component, Fragment } from "react";
      import gql from "graphql-tag";
      import { Query } from "react-apollo";

      import Loading from "../../Loading";
      import DeckItem from "./DeckItem";

      const GET_DECKS = gql`
      query DeckQuery {
      decks @connection(key: "DeckConnection") {
      edges {
      id
      deckName
      createdAt
      cards {
      id
      front
      }
      }
      }
      }
      `;

      class Decks extends Component {
      render() {
      return (
      <Fragment>
      <h1>Deck</h1>
      <Query query={GET_DECKS}>
      {({ data, error, loading }) => {
      if (loading) {
      return <Loading />;
      }
      if (error) {
      return <p>Error</p>;
      }

      const decksToRender = data.decks.edges;

      return (
      <Fragment>
      {console.log(data)}
      {decksToRender.map(deck => (
      <DeckItem key={deck.id} deck={deck} />
      ))}
      </Fragment>
      );
      }}
      </Query>
      </Fragment>
      );
      }
      }

      export default Decks;


      DeckItem index.js



          import React from "react";
      import Moment from "react-moment";
      import { Link } from "react-router-dom";

      export default function DeckItem({ deck: { id, deckName, createdAt } }) {
      return (
      <div>
      <div>
      <h2>
      <Link to={`/deck/${id}`}>{deckName}</Link>
      </h2>
      <p>Description coming soon...</p>
      <h5>
      Created on <Moment format="YYYY-MM-DD HH:mm">{createdAt}</Moment>
      </h5>
      </div>
      </div>
      );
      }


      Cards index.js



          import React, { Component, Fragment } from "react";
      import gql from "graphql-tag";
      import { Query } from "react-apollo";
      import { Link } from "react-router-dom";

      import Loading from "../../../Loading";

      const CARDS_QUERY = gql`
      query CardsQuery($id: ID!) {
      deck(id: $id) {
      id
      deckName
      cards {
      id
      front
      back
      }
      }
      }
      `;

      export class Cards extends Component {
      render() {
      let { id } = this.props.match.params;
      id = parseInt(id);
      return (
      <Fragment>
      <Query query={CARDS_QUERY} variables={{ id }}>
      {({ data, error, loading }) => {
      if (loading) {
      return <Loading />;
      }
      if (error) {
      return <p>Error</p>;
      }
      const {
      id,
      card: { front, back }
      } = data.deck;
      return (
      <div>
      <ul>
      <h1>
      <li>
      <span>Id:</span> {id}
      </li>
      </h1>
      <h4>Details</h4>
      <li>Front: {front}</li>
      <li>Back: {back}</li>
      </ul>
      <hr />
      <Link to="/">Back</Link>
      </div>
      );
      }}
      </Query>
      </Fragment>
      );
      }
      }

      export default Cards;


      Relevant React router routes



          ```
      import { Router, Route } from "react-router-dom";
      ```
      import FlashCardPage from "../FlashCards";
      import Cards from "../FlashCards/Cards/CardsItem";

      import * as routes from "../../constants/routes";

      <Router>
      ```
      <Route
      exact
      path={routes.FLASHCARDS}
      component={() => <FlashCardPage />}
      />
      <Route exact path={routes.CARDS} component={() => <Cards />} />
      </div>
      </Router>


      the path in my routes file is "/deck/:id"



      Console Error log



                  react-dom.development.js:19782 Uncaught TypeError: Cannot read property 'params' of undefined
      at Cards.render (index.js:23)

      index.js:1452 The above error occurred in the <Cards> component:
      in Cards (at App/index.js:42)
      in component (created by Route)
      in Route (at App/index.js:42)
      in div (at App/index.js:19)
      in Router (at App/index.js:18)
      in App (at withSession.js:8)
      in Query (at withSession.js:6)
      in Unknown (at src/index.js:84)
      in ApolloProvider (at src/index.js:83)


      The result should be a deck showing a list of the cards, '/deck/1' should show 2 or 3 cards from my PostgreSQL server. Currently I can only see the decks with a url, but upon clicking, it throws up the error immediately. Other Graphql functions are working correctly, and using Playground the query works just fine, so it seems I'm not passing props correctly. Any additional information needed, I'll be happy to provide. Thank you!







      reactjs postgresql react-router graphql apollo






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 2 at 6:12







      dandmcd

















      asked Jan 2 at 5:42









      dandmcd dandmcd

      236




      236
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The Route component from react-router-dom uses the render-prop pattern to extend the component it renders, providing it props. [1]



          It forwards these props (match, location, history, and staticContext) to the React.Component that is passed for its component prop when it renders. [2]



          In the routes you defined this isn't passed to the FlashCardPage or Cards component because there is stateless function component that wraps them.



          <Route exact path={routes.CARDS} component={() => <Cards />} />


          This stateless function component is passed these props; you can take responsibility to forward these props down to FlashCardPage and Cards components.



          <Route exact path={routes.CARDS} component={(props) => <Cards {...props} />} />


          However, I recommend to get rid of the stateless component which wraps the component rendered in the Route since it's redundant.



          <Route exact path={routes.CARDS} component={Cards} />





          share|improve this answer
























          • Thanks, your instructions worked perfectly and helped me understand why I couldn't get it to work! Your advice about ridding of the stateless component I will certainly follow as well.

            –  dandmcd
            Jan 3 at 2:38











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001733%2fhow-to-solve-typeerror-cannot-read-property-params-of-undefined-with-apollo%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          The Route component from react-router-dom uses the render-prop pattern to extend the component it renders, providing it props. [1]



          It forwards these props (match, location, history, and staticContext) to the React.Component that is passed for its component prop when it renders. [2]



          In the routes you defined this isn't passed to the FlashCardPage or Cards component because there is stateless function component that wraps them.



          <Route exact path={routes.CARDS} component={() => <Cards />} />


          This stateless function component is passed these props; you can take responsibility to forward these props down to FlashCardPage and Cards components.



          <Route exact path={routes.CARDS} component={(props) => <Cards {...props} />} />


          However, I recommend to get rid of the stateless component which wraps the component rendered in the Route since it's redundant.



          <Route exact path={routes.CARDS} component={Cards} />





          share|improve this answer
























          • Thanks, your instructions worked perfectly and helped me understand why I couldn't get it to work! Your advice about ridding of the stateless component I will certainly follow as well.

            –  dandmcd
            Jan 3 at 2:38
















          0














          The Route component from react-router-dom uses the render-prop pattern to extend the component it renders, providing it props. [1]



          It forwards these props (match, location, history, and staticContext) to the React.Component that is passed for its component prop when it renders. [2]



          In the routes you defined this isn't passed to the FlashCardPage or Cards component because there is stateless function component that wraps them.



          <Route exact path={routes.CARDS} component={() => <Cards />} />


          This stateless function component is passed these props; you can take responsibility to forward these props down to FlashCardPage and Cards components.



          <Route exact path={routes.CARDS} component={(props) => <Cards {...props} />} />


          However, I recommend to get rid of the stateless component which wraps the component rendered in the Route since it's redundant.



          <Route exact path={routes.CARDS} component={Cards} />





          share|improve this answer
























          • Thanks, your instructions worked perfectly and helped me understand why I couldn't get it to work! Your advice about ridding of the stateless component I will certainly follow as well.

            –  dandmcd
            Jan 3 at 2:38














          0












          0








          0







          The Route component from react-router-dom uses the render-prop pattern to extend the component it renders, providing it props. [1]



          It forwards these props (match, location, history, and staticContext) to the React.Component that is passed for its component prop when it renders. [2]



          In the routes you defined this isn't passed to the FlashCardPage or Cards component because there is stateless function component that wraps them.



          <Route exact path={routes.CARDS} component={() => <Cards />} />


          This stateless function component is passed these props; you can take responsibility to forward these props down to FlashCardPage and Cards components.



          <Route exact path={routes.CARDS} component={(props) => <Cards {...props} />} />


          However, I recommend to get rid of the stateless component which wraps the component rendered in the Route since it's redundant.



          <Route exact path={routes.CARDS} component={Cards} />





          share|improve this answer













          The Route component from react-router-dom uses the render-prop pattern to extend the component it renders, providing it props. [1]



          It forwards these props (match, location, history, and staticContext) to the React.Component that is passed for its component prop when it renders. [2]



          In the routes you defined this isn't passed to the FlashCardPage or Cards component because there is stateless function component that wraps them.



          <Route exact path={routes.CARDS} component={() => <Cards />} />


          This stateless function component is passed these props; you can take responsibility to forward these props down to FlashCardPage and Cards components.



          <Route exact path={routes.CARDS} component={(props) => <Cards {...props} />} />


          However, I recommend to get rid of the stateless component which wraps the component rendered in the Route since it's redundant.



          <Route exact path={routes.CARDS} component={Cards} />






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 2 at 7:01









          Oluwafemi SuleOluwafemi Sule

          12.5k1735




          12.5k1735













          • Thanks, your instructions worked perfectly and helped me understand why I couldn't get it to work! Your advice about ridding of the stateless component I will certainly follow as well.

            –  dandmcd
            Jan 3 at 2:38



















          • Thanks, your instructions worked perfectly and helped me understand why I couldn't get it to work! Your advice about ridding of the stateless component I will certainly follow as well.

            –  dandmcd
            Jan 3 at 2:38

















          Thanks, your instructions worked perfectly and helped me understand why I couldn't get it to work! Your advice about ridding of the stateless component I will certainly follow as well.

          –  dandmcd
          Jan 3 at 2:38





          Thanks, your instructions worked perfectly and helped me understand why I couldn't get it to work! Your advice about ridding of the stateless component I will certainly follow as well.

          –  dandmcd
          Jan 3 at 2:38




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001733%2fhow-to-solve-typeerror-cannot-read-property-params-of-undefined-with-apollo%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          How to fix TextFormField cause rebuild widget in Flutter