- Giới thiệu Component
- Compoment là những thành phần UI cơ bản, cho phép chia UI thành những thành phần nhỏ và có thể sử dụng lại.
- Component nhận tham số property truyền vào tương tự như tag trong HTML, sau đó render lên UI.
- Cách viết Component
- Sử dụng function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
button { | |
padding: 1em 2em; | |
border-radius: 5px; |
In web development we may face the case that we have to write code to validate the parameter sent from client is satisfied all conditions we defined for that parameter. One strait forward solution that we may think is as example below:
public void register(String email, String name, int age) {
String EMAIL_PATTERN =
"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
+ "+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
Pattern pattern = Pattern.compile(EMAIL_PATTERN);
List<String> forbiddenDomains = Arrays.asList("domain1", "domain2");
if ( email == null || email.trim().equals("")){
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Inherited | |
@InterceptorBinding | |
@Retention(RUNTIME) | |
@Target({METHOD, TYPE}) | |
public @interface Validation { | |
} |
- Cannot mock equals() or hash() method of mock object.
<label><input type="radio" name="filterTodo" value={FilterType.FILTER_ALL} checked={this.state.option === FilterType.FILTER_ALL} onChange={(e)=>this.filterSelected(e)}/>All</label>