Skip to content

Instantly share code, notes, and snippets.

View nmvuong92's full-sized avatar
🎯
Focusing

Vượng Nguyễn nmvuong92

🎯
Focusing
View GitHub Profile
@nmvuong92
nmvuong92 / ES6 generator function.md
Last active September 4, 2018 04:59
ES6 Generator function

nó là gì?

Generator function là một loại function đặc biệt có thể đi vào, đi ra và thoát một số lần. Bạn có thể nghe mọi người mô tả nó là "một hàm có thể bị tạm dừng"

khác gì với function thông thường?

Sự khác biệt duy nhất cho đến nay là Generator function được định nghĩa với function* chứ không phải function.

@nmvuong92
nmvuong92 / Element type is invalid: expected a string for built-in components.md
Last active September 3, 2018 12:16
Fix lỗi Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Change your Package.json file at this line "react-router-redux": "next"

@nmvuong92
nmvuong92 / Làm thế nào để thêm SASS SCSS vào một dự án create-react-app.md
Last active September 3, 2018 04:22
Làm thế nào để thêm SASS/SCSS vào một dự áncreate-react-app

Eject

Cần phải chạy Eject vì điều này là cần thiết để chỉnh sửa thủ công các tệp cấu hình webpack.

npm run eject

Install SASS

cài đặt precompiler (trình biên dịch trước)

npm install sass-loader node-sass --save-dev
@nmvuong92
nmvuong92 / middleware trong react redux.md
Last active July 3, 2023 15:59
middleware trong react redux

Async action là gì?

  • Async => bất đồng bộ?, Action => hành động?
  • là một action trong trạng thái chưa sẵn sàng thực thi ví dụ Fetch API request lên server

Tại sao cần Middleware khi sử dụng Async action?

  • React không hỗ trợ async action => cần 1 middleware trung gian điều phối việc nhận kết quả fetch trả về từ api rồi khi nào mới được dispatch => đảm bảo không bị lỗi chương trình react

Middleware là gì?

  • khác với middleware ở server
@nmvuong92
nmvuong92 / Tạo mới reactjs app.md
Last active September 3, 2018 03:45
Tạo mới reactjs app

0 cài đặt gói app-create-app cli để tạo ứng dụng reactjs chính thống từ trang chủ*

npm install -g create-react-app

1 KIỂM TRA ĐÃ CÀI ĐẶT create-react-app chưa?

create-react-app -V

=>1.5.2

@nmvuong92
nmvuong92 / Cài đặt create-react-app
Created September 3, 2018 03:12
Cài đặt create-react-app
npm install -g create-react-app
@nmvuong92
nmvuong92 / jquery-ajax-standard.js
Last active March 22, 2019 04:33
jquery-ajax-standard.js
//tham request số gọi ajax
var _param = {
pid:1,
color:'red'
};
//gọi ajax
$.ajax({
url:'https://jsonplaceholder.typicode.com/posts', //lấy danh sách bài viết
method:'get', //phương thức post/get
dataType:'json', //kiểu json
@nmvuong92
nmvuong92 / Add_Existing_Project_To_Git.md
Created February 9, 2018 04:02 — forked from alexpchin/Add_Existing_Project_To_Git.md
Add Existing Project To Git Repo

#Adding an existing project to GitHub using the command line

Simple steps to add existing project to Github.

1. Create a new repository on GitHub.

In Terminal, change the current working directory to your local project.

##2. Initialize the local directory as a Git repository.

git init