a tree-select renderer for react.
yarn add @saber2pr/rc-tree
import Tree from "@saber2pr/rc-tree";
const tree = {
path: "root",
name: "root",
children: [
{
path: "root/node",
name: "node",
children: [
{
path: "root/node/node.md",
name: "node",
text: "node\n"
}
]
}
]
};
const App = () => (
<Tree from={tree} map={node => <a href={node.path}>{node.name}</a>} />
);
ReactDOM.render(<App />, document.getElementById("root"));
// map depth
const TreeSelect = (
<Tree
from={tree}
map={(node, depth) => (
<a style={{ color: depth > 1 ? "red" : "green" }}>{node.name}</a>
)}
/>
);
yarn install
yarn run dev
yarn run build
saber2pr