react-facebook
react-facebook copied to clipboard
[Gatsby] React is not defined
I was using react-facebook v8.14.0 on my Gatsby site and updated to v.9.0.5 recently. After the update I tried to build my site again and I saw the following error message.
WebpackError: ReferenceError: React is not defined
Not sure how to fix the problem and would like to see if other people saw this message.
Please try to use latest version. I enabled legacy output and it should work fine now
Hi @seeden,
Just tried v9.0.7 and I still got the error message while building my Gatsby project.
WebpackError: ReferenceError: React is not defined
- index.js:1
[.]/[react-facebook]/dist/esm/index.js:1:4045
Do you know how could I solve this problem? Thanks a lot
Same issue with using a CRA app. There was a change in FaceBookProvider.tsx to remove React from imports, could this be the issue?
import React, { useState, useEffect, type ReactNode } from 'react';
to
import { useState, useEffect, type ReactNode } from 'react';
Linting is showing an error as well. "'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.ts"
It is related to https://github.com/egoist/tsup/issues/579. I will switch to rollup. Sorry for delay
I'm getting the same error in a Vite project.
I am getting the same error in react nextjs project? Any solutions.
Can you try latest version?
@seeden I tried v9.0.8 and it fixes the build problem.