Skip to content

Instantly share code, notes, and snippets.

@tariqulislam
Last active February 3, 2020 06:25
Show Gist options
  • Save tariqulislam/609358a346fc85045eda56252f411f7b to your computer and use it in GitHub Desktop.
Save tariqulislam/609358a346fc85045eda56252f411f7b to your computer and use it in GitHub Desktop.
// ./routes/Home.js
import React, {Component} from 'react'
export class Home extends Component {
/* Add the contructor to initialize the local state of the component */
constructor(props) {
super(props)
/* initial the state for component */
this.state = {
articles: [
{title: "React Redux tutorial 1", id:1},
{title: "Typescript Tutorial for beginners", id:2}
]}
}
render () {
/* distracting the articles array from state */
const {articles} = this.state
return (<ul>{
/* show the item in list using map function javascript */
articles.map(el => <li key={el.id}>{el.title}</li>)
}</ul>)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment