如何在ReactJS中有条件地加载组件 [英] How to load components conditionally in ReactJS

查看:235
本文介绍了如何在ReactJS中有条件地加载组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是来自ReactJS的新入门者。无法获得容易掌握的资源促使我再次敲响SO。问题是这个。我有一个React组件,即 RegisterAccount ,当点击时会拍摄另一个组件(弹出窗口),允许用户填写注册帐户所需的详细信息。现在,一旦帐户成功注册,我想将注册帐户添加为 RegisterAccount 下的另一个组件。如何设置此通讯?

This is from a new starter of ReactJS. Unavailability of easily graspable resources has prompted me to knock at SO again. The issue is this. I have a React Component namely, RegisterAccount which when clicked shoots another component (a pop-up) allowing users to fill in the required details to register an account. Now once an account is successfully registered, I want to add the registered account as another component under RegisterAccount. How can I have this communication set up?

//In RegisterAccount
<addAccount/> //pop-up
<accountAdded/> //if account added, then show this component


推荐答案

我是React的新手。我也在寻找如何。我看到了这个文章
如下所示

I'm new to React. I was also finding how. and I saw this article! It says like belows

render : function()
{
    return (
        <div>
        { true && <AddAccount /> }
        { false && <AccountAdded /> }
        </div>
    );
}

这篇关于如何在ReactJS中有条件地加载组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆