Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

293
Views
How to Render a Link Component

I have this APP component. At the bottom of the code, have a Link to a CountryDetail component. The problem is that I get error when I click on the link.

function App() {
  const [input, setInput] = useState("");
  const [countries, setCountries] = useState([]);
  const [search, setSearch] = useState([]);
  const [status, setStatus] = useState("All");
  const [filteredCountries, setFilteredCountries] = useState([]);



   function onFilter(name) {
    let country = countries.filter((c) => c.name);
    if (countries.length > 0) {
      return country[0];
    } else {
      return null;
    }
  }  

  return (
    <div className="App">
      <header className="App-header"></header>
      <Router>
        <Route path="/" component={Navbar} />

        <Form
          onSearch={onSearch}
          setInput={setInput}
          setSearch={setSearch}
          input={input}
          setStatus={setStatus}
        />

        <AllCountries
          countries={countries}
          search={search}
          filteredCountries={filteredCountries}
        />
        <Route
          exact
          path="/country/:name"
          render={({ match }) => (
            <CountryDetail props={onFilter(match.params.name)} />
          )}
        />
      </Router>
    </div>
  );
}

export default App;


Here is the CountryDetail component:

function CountryDetail({ props }) {
  console.log(props);
  return (
    <div className="details">
      <div className="info">
        <img src={props.flag} className="flags"></img>
        <ul>Name:{props.name}</ul>
        <ul>Native Name: {props.nativeName}</ul>
        <ul>Population:{props.population}</ul>
        <ul>Region:{props.region}</ul>
        <ul>Sub-Region:{props.subregion}</ul>
        <ul>Capital:{props.capital}</ul>
        <ul>Top Level Domain:{props.topLevelDomain}</ul>
        <ul>Currencies:{props.currencies}</ul>
        <ul>Language:{props.language}</ul>
      </div>
    </div>
  );
}

export default CountryDetail;

What Im doing wrong? The CountryDetailed component seems OK for me. On the other hand, here is the console error:

enter image description here

If I consolo log the props, it returns the object, but when I want to render some of the props of that object, it fails...

Any advise for this topic?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!