diff --git a/content/docs/rendering-elements.md b/content/docs/rendering-elements.md index d0c1caf0..7ed7aed6 100644 --- a/content/docs/rendering-elements.md +++ b/content/docs/rendering-elements.md @@ -35,13 +35,7 @@ Applications built with just React usually have a single root DOM node. If you a To render a React element into a root DOM node, pass both to `ReactDOM.render()`: -```js -const element =

Hello, world

; -ReactDOM.render( - element, - document.getElementById('root') -); -``` +`embed:rendering-elements/render-an-element.js` [](codepen://rendering-elements/render-an-element) @@ -55,22 +49,7 @@ With our knowledge so far, the only way to update the UI is to create a new elem Consider this ticking clock example: -```js{8-11} -function tick() { - const element = ( -
-

Hello, world!

-

It is {new Date().toLocaleTimeString()}.

-
- ); - ReactDOM.render( - element, - document.getElementById('root') - ); -} - -setInterval(tick, 1000); -``` +`embed:rendering-elements/update-rendered-element.js` [](codepen://rendering-elements/update-rendered-element) diff --git a/examples/rendering-elements/update-rendered-element.js b/examples/rendering-elements/update-rendered-element.js index 3ed32d25..f16ddcc1 100644 --- a/examples/rendering-elements/update-rendered-element.js +++ b/examples/rendering-elements/update-rendered-element.js @@ -8,6 +8,7 @@ function tick() { ); + // highlight-range{1-4} ReactDOM.render( element, document.getElementById('root')