Skip to content

A simple like component with Font Awesome and event handling.

Notifications You must be signed in to change notification settings

kierandesmond/reactjs-like-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

reactjs-like-component

A simple like component with Font Awesome and event handling.

Here is an example of how you add it to a another component and bubble up events and data.

  1. Import the component

import Like from './components/common/like/like';

  1. Add to your Render section where applicable
{this.handleOnLiked(movie)}} liked={movie.liked}>
  1. Don't forget event handling to be passed to the component and handle event bubbling. Event Handling:

handleOnLiked = movie =>{ const movies = [...this.state.movies]; const index = movies.indexOf(movie); movies[index] = {...movies[index]}; movies[index].liked = !movies[index].liked; this.setState({ movies})

    console.log("Like clicked!", movie)
}

Note: you can pass whatever data you like here, movies is just an example

About

A simple like component with Font Awesome and event handling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published