Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Fetching news headlines from an API and showing 10 news per page and theirs id's. which also refreshes in 10 seconds and new headlines come. With pressing detail button we see details.
Struggling to pass prop from one component using this code:
export interface InitPost {
location: any;
title: string;
url: string;
created_at: Date;
author: string;
const [posts, setPosts] = useState<InitPost[]>([]);
const getDetails = (post: InitPost) => {
navigate("/details", { state: post });
props passed to Details component here is the code:
with error "Module '"react-router-dom"' has no exported member 'RouteComponentProps."
what am I doing wrong?
import React from "react";
import { RouteComponentProps } from "react-router-dom";
import { InitPost } from "./Home";
const Details: React.FC = (
props: RouteComponentProps<{}, any, InitPost | any>
) => {
const post = props.location.state;
return (
<pre>{JSON.stringify(post, null, 2)}</pre>
export default Details;
–
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.