Q:
What are the additional mapping for onClick in React
I have the following onClick function in my React component:
onClick={() => setIsChecked(!isChecked)}
Now I want to write this function in a different way, to gain better maintainability. I have the following function that I want to replace this function with:
onClick={!isChecked? this.toggleCheckBox : this.checkCheckBox}
However, I can't seem to figure out what the additional mapping does for my function. Can anyone help?
A:
You can read more about the delete operator in the docs
Basically it's used to destructure an object. If you remove the? it will make it an expression that returns a boolean and not an object.
So your second example translates to:
onClick={!isChecked? this.toggleCheckBox : this.checkCheckBox}
to:
onClick={(() => this.toggleCheckBox() || this.checkCheckBox())()}
News and information
Number of suspicious people grows in US, China, Israel
A number of people around the world are now getting the hint that terrorists are out to get them, and the list of potential threats keeps growing.
The number of people being reported to authorities as potential extremists has nearly doubled since 2014, when the UN tallied cases of human rights violations and persecution against Muslims, Jews and others.
According to the latest data from the US State Department, the number of people being flagged as suspicious in the U.S. grew nearly 20 percent from 2015 to 2016.
According to that report, the number of people being investigated for terrorist activities in the U.S. also grew in 2016.
The agency listed the following countries as being the most prone to radicalization: Afghanistan, Algeria, Egypt, Libya, Pakistan, Russia, Somalia and Yemen.
In 2017, the State Department said that Iran was the only country to see a decrease in reported suspicious activity among its citizens.Q:
extract image name from url
I am using the below code to extract image name from a given url using regex.
public String getFilename(String url){
String pattern = "([^/]*)$";
Matcher matcher = Pattern.compile(pattern).matcher(url); ac619d1d87
Related links:
Comments