Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/morrismagic/react4


https://github.com/morrismagic/react4

Last synced: 1 day ago
JSON representation

Awesome Lists containing this project

README

        

import React from 'react';

function MovieCard({ title, description, posterURL, rating }) {
return (


{title}

{title}


{description}


Rating: {rating}



);
}

export default MovieCard;

import React from 'react';
import MovieCard from './MovieCard';

function MovieList({ movies }) {
return (


{movies.map((movie, index) => (

))}

);
}

export default MovieList;

import React from 'react';

function Filter({ setFilterTitle, setFilterRating }) {
return (


setFilterTitle(e.target.value)}
style={{ marginRight: "8px", padding: "8px" }}
/>
setFilterRating(e.target.value)}
style={{ padding: "8px" }}
/>

);
}

export default Filter;

import React, { useState } from 'react';
import MovieList from './MovieList';
import Filter from './Filter';

function App() {
const [movies, setMovies] = useState([
{
title: "Inception",
description: "A skilled thief is offered a chance to erase his criminal history.",
posterURL: "https://example.com/inception.jpg",
rating: 5,
},
{
title: "The Matrix",
description: "A computer hacker learns about the true nature of reality.",
posterURL: "https://example.com/matrix.jpg",
rating: 4.5,
},
]);

const [filterTitle, setFilterTitle] = useState('');
const [filterRating, setFilterRating] = useState('');

const filteredMovies = movies.filter((movie) =>
movie.title.toLowerCase().includes(filterTitle.toLowerCase()) &&
movie.rating >= filterRating
);

const addMovie = (movie) => {
setMovies([...movies, movie]);
};

return (


My Movie App



addMovie({ title: "New Movie", description: "New Description", posterURL: "https://example.com/new.jpg", rating: 3 })}>
Add New Movie



);
}

export default App;