Please enable JavaScript.
Coggle requires JavaScript to display documents.
ReactJS (Rendering element (React DOM để matching với DOM trên broswer,…
ReactJS
Rendering element
-
-
-
Nếu chỉ dùng React cho app thì sẽ có 1 root DOM, nếu cho 1 projects đã tồn tại thì sẽ có nhiều DOM hơn
Để React render element bên trong root DOM:
const element = <h1>Hello, world</h1>;
ReactDOM.render(element, document.getElementById('root'));
-
React chỉ thay đổi element khi cần thiết. React sẽ so sánh element và các ele con với phiên bản trước của nó để thực hiện cập nhật mong muốn.
Components và Props
Components là thành phần giao diện được tách biết, nó có thể được sử dụng lại nhiều lân. Comp giống với javascript functions, nó nhận tham số đầu vào tùy ý (được gọi là Props) và return về elem.
-
Tên comp luôn bắt đầu bằng chữ cái viết hoa, chữ cái thường với tag html
-
-
-