From 3a27e214d261a03b90c5c9ededa85d278248eb17 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Thu, 22 Jun 2017 14:58:06 +1000 Subject: [PATCH] Note about common next.js error --- docs/pages/basics/faq/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/pages/basics/faq/index.md b/docs/pages/basics/faq/index.md index 34bd7ff918b5..a5da8ca8a29c 100644 --- a/docs/pages/basics/faq/index.md +++ b/docs/pages/basics/faq/index.md @@ -12,3 +12,10 @@ Create React App does not allow providing options to Jest in your `package.json` ```sh npm test -- --coverage --collectCoverageFrom='["src/**/*.{js,jsx}","!src/**/stories/*"]' ``` + +### I see `ReferenceError: React is not defined` when using storybooks with Next.js + +Next automatically defines `React` for all of your files via a babel plugin. You must define `React` for JSX to work. You can solve this either by: + +1. Adding `import React from 'react'` to your component files. +1. Adding a `.babelrc` that includes [`babel-plugin-react-require`](https://www.npmjs.com/package/babel-plugin-react-require)