reactjs - React/Typescript: How to compose custom components for use with library (rc-tree)? -


i'm using looks 1 of more popular tree components rc-tree react, along it's typescript typedef.

versions:

"typescript": "2.3.4" "react": "15.5.4" "rc-tree": "1.7.3" "@types/rc-tree": "1.4.5" 

i can't figure out how compose custom treenode.

eventually, custom treenode render potentially multiple nodes under single parent - depending on props. want "extend" treenode in few different components define bunch of different "sub-trees" - each of these "sub-trees" specific structures of treenodes (plus defining custom props classes define inputs required generate given type of component).

here simple code show i've tried:

import * react "react"; import {props} "react"; import tree, {treenode} 'rc-tree';   export class treetestscreen extends react.component<any, any> {    constructor(props: any, context: any){     super(props, context);   }    rendersimplenodes(){     return <tree key="tree-root">       {mytreenode.rendercustomnodes({specialtitle: "blah"})}     </tree>;   }    rendercustomnodes(){      return <tree key="tree-root">       <mytreenode specialtitle={"blah"}/>     </tree>;    }     render(){     return this.rendersimplenodes()      // uncaught typeerror:      // return this.rendercustomnodes()   } }  export interface mytreenodeprops extends props<treenode> {   specialtitle: string }   export class mytreenode extends react.component<mytreenodeprops, any> {   static rendercustomnodes(props: mytreenodeprops){     return <treenode        key={`mytreenodekey`}       isleaf={true}       title={props.specialtitle}      />   }   constructor(props: any, context: any){     super(props, context);   }   render(){     return mytreenode.rendercustomnodes(this.props)   } } 

the code in rendersimplenodes() works fine. if try use code in rendercustomnodes(), fail with

domlazytree.js:69 uncaught typeerror: cannot read property 'replacechild' of null 

i thought how i'm supposed make custom components react/typescript. problem here tree/treenode classes of rc-tree (or possibly typedefs)?
or there obvious way i'm trying can't see?


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -