> For the complete documentation index, see [llms.txt](https://jonathan-zhang.gitbook.io/react-steppitguide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jonathan-zhang.gitbook.io/react-steppitguide/orgin-code/react-10.md).

# SimpleReact

简单实现React

```javascript
/* jsx h */
function h(type,props,...children){
  return(type,props,children)
}

//render 函数
function render(node){
  //如果只是一个字符串
  if(typeof node === 'string'){
    return document.createTextNode(node);
  }
  //如果是HTML节点形成
  const $elem = document.createElement(node.type);
  node.children.map(createElement).forEach($elem.appendChild.bind($elem));
  return $elem;
}

//diff 算法
function changed(node_NEW,node_OLD){
  return typeof node_OLD !== typeof node_NEW ||
         typeof node_OLD === 'string' && node_OLD !== node_NEW ||
         node_OLD.type !== node.type
}

//更新算法
function updateElement($parent,node_NEW,node_OLD,index = 0){

}

/* html */
const list = (
  <ul class="list">
    <li>1</li>
    <li>2</li>
  </ul>
)
/*  */
const $root = document.getElementById('root');
$root.appendChild(createElement(list))
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jonathan-zhang.gitbook.io/react-steppitguide/orgin-code/react-10.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
