score:1

Accepted answer

you would need to use react hooks to save the state of the app. you need the state to tell whether the user has logged in or not, and depending on that state, show a button or the text.

first, you need to declare what kind of variable you want, loggedin, and the initial value, false:

const [loggedin, setloggedin] = usestate(false);

then, you can use the loggedin state to determine what to render and update it when the user logs in.

heres the full code:

function app() {
    const [loggedin, setloggedin] = usestate(false);

    const responsefacebook = (response) => {
        const payload = {
            id: response.id,
            name: response.name,
            email: response.email,
            token: response.accesstoken,
            picture: response.picture

        }

        writeuserdata(response.id, response.name, response.email)
    };

    function writeuserdata(id, name, email) {
        fire.database().ref('usersusername/' + name).set({
            fbid: id,
            name: name,
            refdj: "none",
            email: email
        }, function(error) {
            if (error) {
                // the write failed...
            } else {
                // data saved successfully!
                setloggedin(true)

                // change button to text coming soon to ios
            }
        });
    }

    return (
        <div classname="app">
            <header classname="app-header">
            <img src={logo} classname="app-logo" alt="logo" />
            { !loggedin ?
                <facebooklogin
                    //autoload={true}
                    appid="2009920755111111" //app id not created yet
                    fields="name,email,picture"
                    callback={responsefacebook}
                    textbutton = "join with facebook"
                    icon="fa-facebook"
                />
            :
                <p>logged in!</p>
            }
      </header>
    </div>

); }

export default app ;

Related Query

More Query from same tag