import React from "react"; import Preview from "./Preview"; import "./css/RandomPage.css" class RandomPage extends React.Component { constructor(props: P, context: any) { super(props, context); this.state = { videos: [] }; } componentDidMount() { this.loadShuffledvideos(6); } render() { return (

Random Videos

todo here.
{this.state.videos.map(elem => ( ))}
right
); } shuffleclick() { this.loadShuffledvideos(6); } loadShuffledvideos(nr) { const updateRequest = new FormData(); updateRequest.append('action', 'getRandomMovies'); updateRequest.append('number', nr); // fetch all videos available fetch('/php/videoload.php', {method: 'POST', body: updateRequest}) .then((response) => response.json() .then((result) => { this.setState({videos: result}); })) .catch(() => { console.log("no connection to backend"); }); } } export default RandomPage;