seeden / react-facebook

Facebook components like a Login button, Like, Share, Chat, Comments, Page or Embedded Post
MIT License
790 stars 144 forks source link

[React] React is not defined #205

Closed siamahnaf closed 2 years ago

siamahnaf commented 2 years ago

Hello, @seeden, I am try to use react facebook in my project. But when I add Facebook provider to my project, It throwing an error like this ReferenceError: React is not defined

My Project running with-

  1. Next js
  2. Typescript

The version I am using- Latest version 9.0.7

<FacebookProvider appId={process.env.NEXT_PUBLIC_FACEBOOK_APP_ID as string}>
        <FacebookLogins />
 </FacebookProvider>

And this is FacebookLogins.tsx Component-

import { useLogin } from 'react-facebook';

export default function LoginExample() {
    const { login, status, isLoading, error } = useLogin();

    async function handleLogin() {
        try {
            const response = await login({
                scope: 'email',
            });

            console.log(response.status);
        } catch (error: any) {
            console.log(error.message);
        }
    }

    return (
        <button onClick={handleLogin} disabled={isLoading}>
            Login via Facebook
        </button>
    );
}

Where I am wrong, How can I solve it.

image

nekmart commented 2 years ago

Same here. Any Solutions. Please help me.

azhoang commented 2 years ago

Same here. Any Solutions. Please help me.

siamahnaf commented 2 years ago

Waiting for @seeden reply.

seeden commented 2 years ago

I need to bundle library in different way. Meanwhile you can use version 8

siamahnaf commented 2 years ago

But version 8 is not come with typescript. I already install and try version 8.1.4. But it is not come with type declaration. We have to wait for the next version. We are waiting

cgrewon commented 2 years ago

I am facing same issue at create-react-app project. please help me "React is not defined"

seeden commented 2 years ago

Can you try latest version?

cgrewon commented 2 years ago

yes I have tried with latest version and it is working, but when I try to useShare, nothing happened.. :(