-
-
Save azamsharp/04de4405a0239098e11d043364d5900f to your computer and use it in GitHub Desktop.
MovieList
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react' | |
import {Link} from 'react-router-dom' | |
export class MovieList extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
movies : [] | |
} | |
} | |
componentDidMount() { | |
let movies = ["Lord of the Rings", "Taxi", "Margin Call"] | |
this.setState({ | |
movies : movies | |
}) | |
} | |
render() { | |
let movieItems = this.state.movies.map((movie,index) => { | |
let newObj = { | |
pathname : `/movies/${index}`, | |
movie : { | |
name : movie, | |
movieId : index | |
} | |
} | |
return ( | |
<li key = {index}><Link to={`/movies/${index}`}> {movie} </Link> </li> | |
) | |
}) | |
return ( | |
<ul>{movieItems}</ul> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment