简体   繁体   English

如何从js函数调用react组件

[英]how to call react component from js function

In my react js application has below js function that gets called from mobile device.在我的 react js 应用程序中,有以下 js 函数可以从移动设备调用。 Now i want to call react component from this js fuction.现在我想从这个 js 函数调用 react 组件。 please guide.请指导。

var externalcall = {
    callme:function(value)  {
             //here i want to call a react component

        } catch (ex) {
        }
    }
};

You can import the require Component using import(ES6) or require.您可以使用 import(ES6) 或 require 导入 require 组件。 Further, return the component inside your function.此外,返回函数内的组件。

import Component from './src';

        var externalcall = {
            callme:function(value)  {
                     return <Component />
                } catch (ex) {
                }
            }
        };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM