How to automate create Function App with Blob Trigger and Sendgrid Notification through Azure Arm Template and deploy
In previous post (Trigger Email on Blob Trigger), we saw how we can create such…
June 26, 2020
In the ReactJS project, you are having aa parent component and a child component. Let’s assume, we have a Movie and MovieList component.
MovieList is a parent component and is maintaining the list of movies. I want to have the add/remove method in this component. So, this is the correct place to have the remove method. But, this method will be called from the child component: Movie.
We will see how to pass the method reference from parent component to child component and how child component uses that method and pass the argument to the parent component.
import React, { Component } from "react";
import Movie from "../Movie";
export default class TourList extends Component {
state = {
movies: [
{
id: 123,
name: 'Test 1'
},
{
id: 234,
name: 'Test 2'
}
]
};
removeMovie = (id) => {
const { movies } = this.state;
const filteredMovies = movies.filter(movie => movie.id !== id);
this.setState({
tours: filteredMovies
});
};
render() {
return (
<section>
{this.state.movies.map(movie => (
<Movie key={movie.id} movie={movie} removeMovie={this.removeMovie} />
))}
</section>
);
}
}
In this parent component, we are having an array of movies. And is rendering the Movie component from this component. This parent component has a method removeMovie which takes an argument movie-id. We are passing this method reference to Movie component via props.
import React, { Component } from "react";
export default class Movie extends Component {
render() {
const { id, name } = this.props.movie;
const { removeMovie } = this.props;
return (
<article>
<h2>{name}</h2>
<span onClick={() => removeMovie(id)}>
<i className="fas fa-window-close" />
</span>
</article>
);
}
}
Note the interesting things:
This is a very helpful trick in passing the reference of methods to some lower levels of components.
In previous post (Trigger Email on Blob Trigger), we saw how we can create such…
Introduction It is very important to introduce few process so that your code and…
Introduction I was trying to integrate Okta with Spring, and when I deploy the…
While writing JUnit test cases, we encounter cases like we want to initialize a…
Introduction In Azure, assuming you are having a storage container. And, you…
Suppose you have two lists, and you want Union and Intersection of those two…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…