官术网_书友最值得收藏!

The componentDidCatch() method

This method allows us to catch the JavaScript errors in React Components. We can log those errors and display another fallback UI instead of the component tree that crashed.

Now we have a clear idea about component methods that are available in React Components.

Observe the following JavaScript code snippet:

<section>
<h2>My First Example</h2>
</section>
<script>
var root = document.querySelector('section').createShadowRoot();
root.innerHTML = '<style>h2{ color: red; }</style>' +'<h2>Hello World!</h2>';
</script>

Now, observe the following ReactJS code snippet:

var sectionStyle = {
color: 'red'
};
var MyFirstExample = React.createClass({
render: function() {
return (<section><h2 style={sectionStyle}>
Hello World!</h2></section>
)}
})
ReactDOM.render(<MyFirstExample />, renderedNode);

Now, after observing the preceding examples of React and JavaScript, we will have a clear idea of normal HTML encapsulation and ReactJS custom HTML tags.

React isn't an MVC framework; it's a library for building a composable user interface and reusable components. React is used at Facebook in its production stages and instagram.com is entirely built on React.
主站蜘蛛池模板: 南江县| 邵阳市| 延吉市| 巫溪县| 秭归县| 图木舒克市| 常州市| 甘谷县| 兰考县| 吐鲁番市| 涿州市| 许昌市| 伊宁市| 阿鲁科尔沁旗| 威信县| 汶上县| 八宿县| 台江县| 沁源县| 赤水市| 龙州县| 五常市| 新河县| 毕节市| 红桥区| 白城市| 锡林浩特市| 开封市| 文化| 广昌县| 汨罗市| 杭锦旗| 吴江市| 清镇市| 苗栗市| 南通市| 耒阳市| 临西县| 三门峡市| 方山县| 竹北市|