React có sử dụng HTML và CSS không?

“CSS-in-JS” đề cập đến một mẫu trong đó CSS ​​được tạo bằng JavaScript thay vì được xác định trong các tệp bên ngoài

Lưu ý rằng chức năng này không phải là một phần của React, nhưng được cung cấp bởi các thư viện của bên thứ ba. React không có ý kiến ​​về cách định nghĩa các kiểu;

Tôi có thể tạo hoạt ảnh trong React không?

React có thể được sử dụng để tăng sức mạnh cho hoạt ảnh. Xem React Transition Group, React Motion, React Spring hoặc Framer Motion chẳng hạn

React triển khai hệ thống DOM độc lập với trình duyệt để có hiệu suất và khả năng tương thích giữa các trình duyệt. Chúng tôi đã nhân cơ hội này để dọn sạch một số góc cạnh thô trong quá trình triển khai DOM của trình duyệt

Trong React, tất cả thuộc tính và thuộc tính DOM (bao gồm cả trình xử lý sự kiện) phải là camelCased. Ví dụ, thuộc tính HTML

const divStyle = {
  color: 'blue',
  backgroundImage: 'url(' + imgUrl + ')',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!div>;
}
3 tương ứng với thuộc tính
const divStyle = {
  color: 'blue',
  backgroundImage: 'url(' + imgUrl + ')',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!div>;
}
4 trong React. Ngoại lệ là các thuộc tính
const divStyle = {
  color: 'blue',
  backgroundImage: 'url(' + imgUrl + ')',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!div>;
}
5 và
const divStyle = {
  color: 'blue',
  backgroundImage: 'url(' + imgUrl + ')',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!div>;
}
6, các thuộc tính này phải được viết thường. Ví dụ: bạn có thể giữ
const divStyle = {
  color: 'blue',
  backgroundImage: 'url(' + imgUrl + ')',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!div>;
}
7 là
const divStyle = {
  color: 'blue',
  backgroundImage: 'url(' + imgUrl + ')',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!div>;
}
7

Sự khác biệt trong thuộc tính

Có một số thuộc tính hoạt động khác nhau giữa React và HTML

đã kiểm tra

Thuộc tính

const divStyle = {
  color: 'blue',
  backgroundImage: 'url(' + imgUrl + ')',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!div>;
}
9 được hỗ trợ bởi các thành phần kiểu
const divStyle = {
  WebkitTransition: 'all', // note the capital 'W' here
  msTransition: 'all' // 'ms' is the only lowercase vendor prefix
};

function ComponentWithTransition() {
  return <div style={divStyle}>This should work cross-browserdiv>;
}
1 hoặc
const divStyle = {
  WebkitTransition: 'all', // note the capital 'W' here
  msTransition: 'all' // 'ms' is the only lowercase vendor prefix
};

function ComponentWithTransition() {
  return <div style={divStyle}>This should work cross-browserdiv>;
}
2. Bạn có thể sử dụng nó để đặt xem thành phần có được kiểm tra hay không. Điều này hữu ích cho việc xây dựng các thành phần được kiểm soát.
const divStyle = {
  WebkitTransition: 'all', // note the capital 'W' here
  msTransition: 'all' // 'ms' is the only lowercase vendor prefix
};

function ComponentWithTransition() {
  return <div style={divStyle}>This should work cross-browserdiv>;
}
3 là giá trị tương đương không được kiểm soát, đặt xem thành phần có được kiểm tra khi lắp lần đầu hay không

tên lớp

Để chỉ định một lớp CSS, hãy sử dụng thuộc tính

const divStyle = {
  WebkitTransition: 'all', // note the capital 'W' here
  msTransition: 'all' // 'ms' is the only lowercase vendor prefix
};

function ComponentWithTransition() {
  return <div style={divStyle}>This should work cross-browserdiv>;
}
4. Điều này áp dụng cho tất cả các phần tử DOM và SVG thông thường như
,
const divStyle = {
  WebkitTransition: 'all', // note the capital 'W' here
  msTransition: 'all' // 'ms' is the only lowercase vendor prefix
};

function ComponentWithTransition() {
  return <div style={divStyle}>This should work cross-browserdiv>;
}
6 và các phần tử khác

Nếu bạn sử dụng Phản ứng với các Thành phần Web (không phổ biến), hãy sử dụng thuộc tính

const divStyle = {
  WebkitTransition: 'all', // note the capital 'W' here
  msTransition: 'all' // 'ms' is the only lowercase vendor prefix
};

function ComponentWithTransition() {
  return <div style={divStyle}>This should work cross-browserdiv>;
}
7 để thay thế

nguy hiểmSetInnerHTML

const divStyle = {
  WebkitTransition: 'all', // note the capital 'W' here
  msTransition: 'all' // 'ms' is the only lowercase vendor prefix
};

function ComponentWithTransition() {
  return <div style={divStyle}>This should work cross-browserdiv>;
}
8 là sự thay thế của React cho việc sử dụng
const divStyle = {
  WebkitTransition: 'all', // note the capital 'W' here
  msTransition: 'all' // 'ms' is the only lowercase vendor prefix
};

function ComponentWithTransition() {
  return <div style={divStyle}>This should work cross-browserdiv>;
}
9 trong trình duyệt DOM. Nói chung, việc đặt HTML từ mã là rủi ro vì rất dễ khiến người dùng của bạn vô tình bị tấn công bằng tập lệnh chéo trang (XSS). Vì vậy, bạn có thể đặt HTML trực tiếp từ React, nhưng bạn phải nhập
const divStyle = {
  WebkitTransition: 'all', // note the capital 'W' here
  msTransition: 'all' // 'ms' is the only lowercase vendor prefix
};

function ComponentWithTransition() {
  return <div style={divStyle}>This should work cross-browserdiv>;
}
8 và chuyển một đối tượng bằng phím
// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
1, để nhắc nhở bản thân rằng điều đó nguy hiểm. Ví dụ

function createMarkup() {
  return {__html: 'First · Second'};
}

function MyComponent() {
  return <div dangerouslySetInnerHTML={createMarkup()} />;
}

htmlDành cho

// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
2 là một từ dành riêng trong JavaScript, nên các phần tử React sử dụng
// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
3 để thay thế

onChange

Sự kiện

// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
4 hoạt động như bạn mong đợi. bất cứ khi nào một trường biểu mẫu được thay đổi, sự kiện này sẽ được kích hoạt. Chúng tôi cố tình không sử dụng hành vi trình duyệt hiện có vì
// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
4 là cách gọi sai cho hành vi của nó và React dựa vào sự kiện này để xử lý đầu vào của người dùng trong thời gian thực

đã chọn

Nếu bạn muốn đánh dấu một là đã chọn, hãy tham khảo giá trị của tùy chọn đó trong

// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
7 trong số
const divStyle = {
  color: 'blue',
  backgroundImage: 'url(' + imgUrl + ')',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!div>;
}
1 của nó. Kiểm tra để được hướng dẫn chi tiết

Phong cách

Ghi chú

Một số ví dụ trong tài liệu sử dụng

// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
9 để thuận tiện, nhưng việc sử dụng thuộc tính
// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
9 làm phương tiện chính của các thành phần kiểu dáng thường không được khuyến nghị. Trong hầu hết các trường hợp, nên được sử dụng để tham chiếu các lớp được xác định trong biểu định kiểu CSS bên ngoài.
// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
9 thường được sử dụng nhất trong các ứng dụng React để thêm các kiểu được tính toán động vào thời điểm kết xuất. Xem thêm Câu hỏi thường gặp. Tạo kiểu và CSS

Thuộc tính

// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
9 chấp nhận đối tượng JavaScript có thuộc tính camelCased thay vì chuỗi CSS. Điều này phù hợp với thuộc tính DOM
// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
9 JavaScript, hiệu quả hơn và ngăn ngừa các lỗ hổng bảo mật XSS. Ví dụ

const divStyle = {
  color: 'blue',
  backgroundImage: 'url(' + imgUrl + ')',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!div>;
}

Lưu ý rằng các kiểu không được tự động thêm tiền tố. Để hỗ trợ các trình duyệt cũ hơn, bạn cần cung cấp các thuộc tính kiểu tương ứng

const divStyle = {
  WebkitTransition: 'all', // note the capital 'W' here
  msTransition: 'all' // 'ms' is the only lowercase vendor prefix
};

function ComponentWithTransition() {
  return <div style={divStyle}>This should work cross-browserdiv>;
}

Các khóa kiểu là camelCased để nhất quán với việc truy cập các thuộc tính trên các nút DOM từ JS (e. g.

<div tabIndex={-1} />      // Just like node.tabIndex DOM API
<div className="Button" /> // Just like node.className DOM API
<input readOnly={true} />  // Just like node.readOnly DOM API
5). Tiền tố của nhà cung cấp không phải là
<div tabIndex={-1} />      // Just like node.tabIndex DOM API
<div className="Button" /> // Just like node.className DOM API
<input readOnly={true} />  // Just like node.readOnly DOM API
6 phải bắt đầu bằng chữ in hoa. Đây là lý do tại sao
<div tabIndex={-1} />      // Just like node.tabIndex DOM API
<div className="Button" /> // Just like node.className DOM API
<input readOnly={true} />  // Just like node.readOnly DOM API
7 có chữ hoa “W”

React sẽ tự động thêm hậu tố “px” vào một số thuộc tính kiểu nội tuyến số. Nếu bạn muốn sử dụng các đơn vị khác ngoài “px”, hãy chỉ định giá trị dưới dạng chuỗi với đơn vị mong muốn. Ví dụ

// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>

Tuy nhiên, không phải tất cả các thuộc tính kiểu đều được chuyển đổi thành chuỗi pixel. Một số cái vẫn không có đơn vị (ví dụ:

<div tabIndex={-1} />      // Just like node.tabIndex DOM API
<div className="Button" /> // Just like node.className DOM API
<input readOnly={true} />  // Just like node.readOnly DOM API
8,
<div tabIndex={-1} />      // Just like node.tabIndex DOM API
<div className="Button" /> // Just like node.className DOM API
<input readOnly={true} />  // Just like node.readOnly DOM API
9,
accept acceptCharset accessKey action allowFullScreen alt async autoComplete
autoFocus autoPlay capture cellPadding cellSpacing challenge charSet checked
cite classID className colSpan cols content contentEditable contextMenu controls
controlsList coords crossOrigin data dateTime default defer dir disabled
download draggable encType form formAction formEncType formMethod formNoValidate
formTarget frameBorder headers height hidden high href hrefLang htmlFor
httpEquiv icon id inputMode integrity is keyParams keyType kind label lang list
loop low manifest marginHeight marginWidth max maxLength media mediaGroup method
min minLength multiple muted name noValidate nonce open optimum pattern
placeholder poster preload profile radioGroup readOnly rel required reversed
role rowSpan rows sandbox scope scoped scrolling seamless selected shape size
sizes span spellCheck src srcDoc srcLang srcSet start step style summary
tabIndex target title type useMap value width wmode wrap
0). Một danh sách đầy đủ các thuộc tính không có đơn vị có thể được nhìn thấy

triệt tiêu Nội dungCó thể chỉnh sửaCảnh báo

Thông thường, sẽ có cảnh báo khi phần tử có phần tử con cũng được đánh dấu là

accept acceptCharset accessKey action allowFullScreen alt async autoComplete
autoFocus autoPlay capture cellPadding cellSpacing challenge charSet checked
cite classID className colSpan cols content contentEditable contextMenu controls
controlsList coords crossOrigin data dateTime default defer dir disabled
download draggable encType form formAction formEncType formMethod formNoValidate
formTarget frameBorder headers height hidden high href hrefLang htmlFor
httpEquiv icon id inputMode integrity is keyParams keyType kind label lang list
loop low manifest marginHeight marginWidth max maxLength media mediaGroup method
min minLength multiple muted name noValidate nonce open optimum pattern
placeholder poster preload profile radioGroup readOnly rel required reversed
role rowSpan rows sandbox scope scoped scrolling seamless selected shape size
sizes span spellCheck src srcDoc srcLang srcSet start step style summary
tabIndex target title type useMap value width wmode wrap
1, vì phần tử đó sẽ không hoạt động. Thuộc tính này chặn cảnh báo đó. Không sử dụng cái này trừ khi bạn đang xây dựng một thư viện như Bản nháp. js quản lý thủ công
accept acceptCharset accessKey action allowFullScreen alt async autoComplete
autoFocus autoPlay capture cellPadding cellSpacing challenge charSet checked
cite classID className colSpan cols content contentEditable contextMenu controls
controlsList coords crossOrigin data dateTime default defer dir disabled
download draggable encType form formAction formEncType formMethod formNoValidate
formTarget frameBorder headers height hidden high href hrefLang htmlFor
httpEquiv icon id inputMode integrity is keyParams keyType kind label lang list
loop low manifest marginHeight marginWidth max maxLength media mediaGroup method
min minLength multiple muted name noValidate nonce open optimum pattern
placeholder poster preload profile radioGroup readOnly rel required reversed
role rowSpan rows sandbox scope scoped scrolling seamless selected shape size
sizes span spellCheck src srcDoc srcLang srcSet start step style summary
tabIndex target title type useMap value width wmode wrap
1

triệt tiêuHydrationCảnh báo

Nếu bạn sử dụng kết xuất React phía máy chủ, thông thường sẽ có cảnh báo khi máy chủ và máy khách hiển thị nội dung khác nhau. Tuy nhiên, trong một số trường hợp hiếm hoi, rất khó hoặc không thể đảm bảo kết quả khớp chính xác. Ví dụ: dấu thời gian dự kiến ​​sẽ khác nhau trên máy chủ và trên máy khách

Nếu bạn đặt

accept acceptCharset accessKey action allowFullScreen alt async autoComplete
autoFocus autoPlay capture cellPadding cellSpacing challenge charSet checked
cite classID className colSpan cols content contentEditable contextMenu controls
controlsList coords crossOrigin data dateTime default defer dir disabled
download draggable encType form formAction formEncType formMethod formNoValidate
formTarget frameBorder headers height hidden high href hrefLang htmlFor
httpEquiv icon id inputMode integrity is keyParams keyType kind label lang list
loop low manifest marginHeight marginWidth max maxLength media mediaGroup method
min minLength multiple muted name noValidate nonce open optimum pattern
placeholder poster preload profile radioGroup readOnly rel required reversed
role rowSpan rows sandbox scope scoped scrolling seamless selected shape size
sizes span spellCheck src srcDoc srcLang srcSet start step style summary
tabIndex target title type useMap value width wmode wrap
3 thành
accept acceptCharset accessKey action allowFullScreen alt async autoComplete
autoFocus autoPlay capture cellPadding cellSpacing challenge charSet checked
cite classID className colSpan cols content contentEditable contextMenu controls
controlsList coords crossOrigin data dateTime default defer dir disabled
download draggable encType form formAction formEncType formMethod formNoValidate
formTarget frameBorder headers height hidden high href hrefLang htmlFor
httpEquiv icon id inputMode integrity is keyParams keyType kind label lang list
loop low manifest marginHeight marginWidth max maxLength media mediaGroup method
min minLength multiple muted name noValidate nonce open optimum pattern
placeholder poster preload profile radioGroup readOnly rel required reversed
role rowSpan rows sandbox scope scoped scrolling seamless selected shape size
sizes span spellCheck src srcDoc srcLang srcSet start step style summary
tabIndex target title type useMap value width wmode wrap
4, React sẽ không cảnh báo bạn về sự không khớp trong thuộc tính và nội dung của phần tử đó. Nó chỉ hoạt động ở độ sâu một tầng và được dùng làm cửa thoát hiểm. Đừng lạm dụng nó. Bạn có thể đọc thêm về hydrat hóa trong

giá trị

Thuộc tính

// Result style: '10px'
<div style={{ height: 10 }}>
  Hello World!
div>

// Result style: '10%'
<div style={{ height: '10%' }}>
  Hello World!
div>
7 được hỗ trợ bởi các thành phần ,
const divStyle = {
  color: 'blue',
  backgroundImage: 'url(' + imgUrl + ')',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!div>;
}
1 và
const divStyle = {
  color: 'blue',
  backgroundImage: 'url(' + imgUrl + ')',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!div>;
}
2. Bạn có thể sử dụng nó để đặt giá trị của thành phần. Điều này hữu ích cho việc xây dựng các thành phần được kiểm soát.
accentHeight accumulate additive alignmentBaseline allowReorder alphabetic
amplitude arabicForm ascent attributeName attributeType autoReverse azimuth
baseFrequency baseProfile baselineShift bbox begin bias by calcMode capHeight
clip clipPath clipPathUnits clipRule colorInterpolation
colorInterpolationFilters colorProfile colorRendering contentScriptType
contentStyleType cursor cx cy d decelerate descent diffuseConstant direction
display divisor dominantBaseline dur dx dy edgeMode elevation enableBackground
end exponent externalResourcesRequired fill fillOpacity fillRule filter
filterRes filterUnits floodColor floodOpacity focusable fontFamily fontSize
fontSizeAdjust fontStretch fontStyle fontVariant fontWeight format from fx fy
g1 g2 glyphName glyphOrientationHorizontal glyphOrientationVertical glyphRef
gradientTransform gradientUnits hanging horizAdvX horizOriginX ideographic
imageRendering in in2 intercept k k1 k2 k3 k4 kernelMatrix kernelUnitLength
kerning keyPoints keySplines keyTimes lengthAdjust letterSpacing lightingColor
limitingConeAngle local markerEnd markerHeight markerMid markerStart
markerUnits markerWidth mask maskContentUnits maskUnits mathematical mode
numOctaves offset opacity operator order orient orientation origin overflow
overlinePosition overlineThickness paintOrder panose1 pathLength
patternContentUnits patternTransform patternUnits pointerEvents points
pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits
r radius refX refY renderingIntent repeatCount repeatDur requiredExtensions
requiredFeatures restart result rotate rx ry scale seed shapeRendering slope
spacing specularConstant specularExponent speed spreadMethod startOffset
stdDeviation stemh stemv stitchTiles stopColor stopOpacity
strikethroughPosition strikethroughThickness string stroke strokeDasharray
strokeDashoffset strokeLinecap strokeLinejoin strokeMiterlimit strokeOpacity
strokeWidth surfaceScale systemLanguage tableValues targetX targetY textAnchor
textDecoration textLength textRendering to transform u1 u2 underlinePosition
underlineThickness unicode unicodeBidi unicodeRange unitsPerEm vAlphabetic
vHanging vIdeographic vMathematical values vectorEffect version vertAdvY
vertOriginX vertOriginY viewBox viewTarget visibility widths wordSpacing
writingMode x x1 x2 xChannelSelector xHeight xlinkActuate xlinkArcrole
xlinkHref xlinkRole xlinkShow xlinkTitle xlinkType xmlns xmlnsXlink xmlBase
xmlLang xmlSpace y y1 y2 yChannelSelector z zoomAndPan
0 là giá trị tương đương không được kiểm soát, đặt giá trị của thành phần khi nó được gắn lần đầu tiên

Tất cả các thuộc tính HTML được hỗ trợ

Kể từ React 16, mọi thuộc tính DOM tiêu chuẩn hoặc tùy chỉnh đều được hỗ trợ đầy đủ

React luôn cung cấp API tập trung vào JavaScript cho DOM. Vì các thành phần React thường có cả props tùy chỉnh và liên quan đến DOM, nên React sử dụng quy ước

accentHeight accumulate additive alignmentBaseline allowReorder alphabetic
amplitude arabicForm ascent attributeName attributeType autoReverse azimuth
baseFrequency baseProfile baselineShift bbox begin bias by calcMode capHeight
clip clipPath clipPathUnits clipRule colorInterpolation
colorInterpolationFilters colorProfile colorRendering contentScriptType
contentStyleType cursor cx cy d decelerate descent diffuseConstant direction
display divisor dominantBaseline dur dx dy edgeMode elevation enableBackground
end exponent externalResourcesRequired fill fillOpacity fillRule filter
filterRes filterUnits floodColor floodOpacity focusable fontFamily fontSize
fontSizeAdjust fontStretch fontStyle fontVariant fontWeight format from fx fy
g1 g2 glyphName glyphOrientationHorizontal glyphOrientationVertical glyphRef
gradientTransform gradientUnits hanging horizAdvX horizOriginX ideographic
imageRendering in in2 intercept k k1 k2 k3 k4 kernelMatrix kernelUnitLength
kerning keyPoints keySplines keyTimes lengthAdjust letterSpacing lightingColor
limitingConeAngle local markerEnd markerHeight markerMid markerStart
markerUnits markerWidth mask maskContentUnits maskUnits mathematical mode
numOctaves offset opacity operator order orient orientation origin overflow
overlinePosition overlineThickness paintOrder panose1 pathLength
patternContentUnits patternTransform patternUnits pointerEvents points
pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits
r radius refX refY renderingIntent repeatCount repeatDur requiredExtensions
requiredFeatures restart result rotate rx ry scale seed shapeRendering slope
spacing specularConstant specularExponent speed spreadMethod startOffset
stdDeviation stemh stemv stitchTiles stopColor stopOpacity
strikethroughPosition strikethroughThickness string stroke strokeDasharray
strokeDashoffset strokeLinecap strokeLinejoin strokeMiterlimit strokeOpacity
strokeWidth surfaceScale systemLanguage tableValues targetX targetY textAnchor
textDecoration textLength textRendering to transform u1 u2 underlinePosition
underlineThickness unicode unicodeBidi unicodeRange unitsPerEm vAlphabetic
vHanging vIdeographic vMathematical values vectorEffect version vertAdvY
vertOriginX vertOriginY viewBox viewTarget visibility widths wordSpacing
writingMode x x1 x2 xChannelSelector xHeight xlinkActuate xlinkArcrole
xlinkHref xlinkRole xlinkShow xlinkTitle xlinkType xmlns xmlnsXlink xmlBase
xmlLang xmlSpace y y1 y2 yChannelSelector z zoomAndPan
1 giống như API DOM

<div tabIndex={-1} />      // Just like node.tabIndex DOM API
<div className="Button" /> // Just like node.className DOM API
<input readOnly={true} />  // Just like node.readOnly DOM API

Các đạo cụ này hoạt động tương tự như các thuộc tính HTML tương ứng, ngoại trừ các trường hợp đặc biệt được nêu ở trên

React có thay thế HTML và CSS không?

Điều khiến React trở thành một thư viện đáng học như vậy là nó không thay thế HTML . Nó tận dụng sự phổ biến và sức mạnh của HTML như là ngôn ngữ lập trình phổ biến nhất, bằng cách cho phép bạn sử dụng cú pháp rất giống với HTML để xây dựng giao diện và thêm các tính năng động cho nó bằng JavaScript.

Reactjs có sử dụng HTML không?

Ứng dụng React thường được xây dựng xung quanh một phần tử HTML duy nhất .

React có liên quan đến CSS không?

Viết CSS trong biểu định kiểu có lẽ là cách tiếp cận cơ bản và phổ biến nhất để tạo kiểu cho ứng dụng React , nhưng bạn không nên dễ dàng bỏ qua cách này. Các kiểu viết trong biểu định kiểu CSS "đơn giản" ngày càng trở nên tốt hơn, do ngày càng có nhiều tính năng có sẵn trong tiêu chuẩn CSS.