组件是不确定的,是一个变量传入的,可以使用如下方法渲染

export function insertModal(cfg){
    let {id,refKey,modal} = cfg;
    let ModalKey = modal || 'Modal';
    id = id || +new Date();
    let div = document.createElement('div');
    div.id = id;
    document.body.appendChild(div);
    refKey = refKey || 'myRef' + id;
    window[refKey + 'Ref'] = React.createRef();
    ReactDOM.render(React.createElement(ModalKey,{ref:window[refKey + 'Ref']}), div);
}

 

出处:https://stackoverflow.com/questions/29875869/react-jsx-dynamic-component-name

相关文章:

  • 2021-06-22
  • 2021-08-04
  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
  • 2021-10-20
  • 2022-12-23
  • 2022-02-05
相关资源
相似解决方案