Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
1,009
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useState } from 'react';
  2. import './Playlist.css';
  3. import TrackList from '../TrackList/TrackList'
  4.  
  5. export class Playlist extends React.Component {
  6.     constructor(props) {
  7.         super(props);
  8.  
  9.         this.state = {
  10.             inputVal: ''
  11.         }
  12.  
  13.         this.handleChange = this.handleChange.bind(this);
  14.     }
  15.  
  16.     handleChange(e) {
  17.         this.setState({
  18.             inputVal: e.target.value
  19.         })
  20.     }
  21.  
  22.     render(){
  23.         return(
  24.             <div className="Playlist">
  25.                 <input value="New Playlist" onChange={this.handleChange}/>
  26.                 <TrackList />
  27.                 <button className="Playlist-save">SAVE TO SPOTIFY</button>
  28.             </div>
  29.         )
  30.     }
  31. }
  32.  
  33. // written in Hooks
  34.  
  35. export default function Playlist(props) {
  36.  
  37.     const [inputVal, setVal] = useState('initial val');
  38.  
  39.     function handleChange(e) {
  40.         setVal(e.target.value);
  41.     }
  42.     return(
  43.         <div className="Playlist">
  44.             <input
  45.             value={inputVal}
  46.             onChange={handleChange}
  47.             />
  48.             <TrackList />
  49.             <button className="Playlist-save">SAVE TO SPOTIFY</button>
  50.         </div>
  51.     )
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement