Error match is not defined no-undef in react.js


Through <Route> , I direct to different components. In one of them I need to pass a parameter, and I do it this way:

const AppRoutes = () =>

        <Route path='/:slug' component={Articulo} />
        <Route exact path='/' component={App} />
        <Route component={Page404} />

export default AppRoutes;

The component <articulo> I created it in a separate file, but something I'm doing wrong and I do not know what. The file I have it like this:

import React, { Component } from 'react';

class Articulo extends Component {

  render() {
    return (<h2>Este es el slug del artículo: {match.params.slug}</h2>)


export default Articulo;

However, it returns an error:


'match' is not defined no-undef

All the documentation that I found to create the component in the same file in this way:

const Articulo = () => (
  <h1>Este es el slug: {match.params.slug}</h1>

This way there would be no problem, but I need to do it in a separate component.

asked by JetLagFox 11.07.2018 в 01:44

0 answers