React DOM Components
பொதுவான components
உலாவியில் உள்ளமைந்த அனைத்து components சில props மற்றும் events-ஐ support செய்கின்றன.
இதில் ref மற்றும் dangerouslySetInnerHTML போன்ற React-specific props அடங்கும்.
Form components
உலாவியில் உள்ளமைந்த இந்த components user input-ஐ ஏற்கின்றன:
இவை React-இல் சிறப்பு வாய்ந்தவை; ஏனெனில் value prop-ஐ இவற்றுக்கு pass செய்தால் அவை controlled ஆகும்.
Resource மற்றும் metadata components
உலாவியில் உள்ளமைந்த இந்த components external resources load செய்யவோ document-ஐ metadata உடன் annotate செய்யவோ உதவுகின்றன:
இவை React-இல் சிறப்பு வாய்ந்தவை; ஏனெனில் React அவற்றை document head-இல் render செய்யவும், resources load ஆகும் போது suspend செய்யவும், குறிப்பிட்ட ஒவ்வொரு component-ன் reference page-இல் விவரிக்கப்பட்டுள்ள பிற behaviors-ஐ செயல்படுத்தவும் முடியும்.
அனைத்து HTML components
உலாவியில் உள்ளமைந்த அனைத்து HTML components-ஐ React support செய்கிறது. இதில் அடங்குபவை:
<aside><audio><b><base><bdi><bdo><blockquote><body><br><button><canvas><caption><cite><code><col><colgroup><data><datalist><dd><del><details><dfn><dialog><div><dl><dt><em><embed><fieldset><figcaption><figure><footer><form><h1><head><header><hgroup><hr><html><i><iframe><img><input><ins><kbd><label><legend><li><link><main><map><mark><menu><meta><meter><nav><noscript><object><ol><optgroup><option><output><p><picture><pre><progress><q><rp><rt><ruby><s><samp><script><section><select><slot><small><source><span><strong><style><sub><summary><sup><table><tbody><td><template><textarea><tfoot><th><thead><time><title><tr><track><u><ul><var><video><wbr>
Custom HTML elements
<my-element> போல dash கொண்ட tag-ஐ render செய்தால், நீங்கள் custom HTML element render செய்ய விரும்புகிறீர்கள் என்று React கருதும்.
உலாவியில் உள்ளமைந்த HTML element-ஐ is attribute உடன் render செய்தாலும், அது custom element ஆகவே நடத்தப்படும்.
Custom elements-இல் values set செய்தல்
Custom elements-க்கு data pass செய்ய இரண்டு முறைகள் உள்ளன:
- Attributes: Markup-இல் display ஆகும்; string values-க்கு மட்டுமே set செய்ய முடியும்
- Properties: Markup-இல் display ஆகாது; arbitrary JavaScript values-க்கு set செய்ய முடியும்
Default-ஆக, JSX-இல் bound செய்யப்பட்ட values-ஐ React attributes ஆக pass செய்யும்:
<my-element value="Hello, world!"></my-element>Custom elements-க்கு pass செய்யப்படும் non-string JavaScript values default-ஆக serialize செய்யப்படும்:
// Will be passed as `"1,2,3"` as the output of `[1,2,3].toString()`
<my-element value={[1,2,3]}></my-element>ஆனால் construction நேரத்தில் class-இல் property name தோன்றினால், custom element-ன் அந்த property arbitrary values pass செய்யக்கூடியது என்று React அறிந்துகொள்ளும்:
export class MyElement extends HTMLElement { constructor() { super(); // The value here will be overwritten by React // when initialized as an element this.value = undefined; } connectedCallback() { this.innerHTML = this.value.join(", "); } }
Custom elements-இல் events கேட்குதல்
Custom elements பயன்படுத்தும்போது பொதுவான pattern: event ஏற்படும் போது call செய்ய function ஏற்குவதற்குப் பதிலாக அவை CustomEvents dispatch செய்யலாம். JSX மூலம் event-க்கு bind செய்யும்போது on prefix பயன்படுத்தி இந்த events-ஐ listen செய்யலாம்.
export function App() { return ( <my-element onspeak={e => console.log(e.detail.message)} ></my-element> ) }
அனைத்து SVG components
உலாவியில் உள்ளமைந்த அனைத்து SVG components-ஐ React support செய்கிறது. இதில் அடங்குபவை:
<a><animate><animateMotion><animateTransform><circle><clipPath><defs><desc><discard><ellipse><feBlend><feColorMatrix><feComponentTransfer><feComposite><feConvolveMatrix><feDiffuseLighting><feDisplacementMap><feDistantLight><feDropShadow><feFlood><feFuncA><feFuncB><feFuncG><feFuncR><feGaussianBlur><feImage><feMerge><feMergeNode><feMorphology><feOffset><fePointLight><feSpecularLighting><feSpotLight><feTile><feTurbulence><filter><foreignObject><g><hatch><hatchpath><image><line><linearGradient><marker><mask><metadata><mpath><path><pattern><polygon><polyline><radialGradient><rect><script><set><stop><style><svg><switch><symbol><text><textPath><title><tspan><use><view>