import React from "react";
import { render } from "react-dom";
let $container;
render(
<b ref={e => ($container = e)}>
{"one"}two{"six"}
</b>,
document.getElementById("root")
);
console.log($container);
會得到我的<b>
元素:
<b>
<!-- react-text: 2 -->
"one"
<!-- /react-text -->
<!-- react-text: 3 -->
"two"
<!-- /react-text -->
<!-- react-text: 4 -->
"six"
<!-- /react-text -->
</b>
但是,如果我想要什麼的TextNodes的一個參考?
有沒有公開的API?也許特殊的type
爲TextNodes,所以我可以通過道具createElement
?
你想達到什麼目的? – lukaleli
很難解釋,因爲我甚至沒有使用反應。我試圖用一個名爲nativejsx的庫做類似的事情,並想知道這是否可能與反應。 – pomber