Description
Bug report
Describe the bug
Every time I try to update an item using the admin UI, the toast message that used to appear after clicking "Save" fails to do so, and an error appears in the console:
Uncaught (in promise) ReferenceError: React is not defined
at toastItemSuccess (util.js:40:5)
at _callee$ (index.js:223:21)
at tryCatch (runtime.js:63:15)
at Generator.invoke [as _invoke] (runtime.js:294:1)
at Generator.next (runtime.js:119:1)
at asyncGeneratorStep (main.5038e4a099fa9664fade.bundle.js:109450:103)
at _next (main.5038e4a099fa9664fade.bundle.js:109452:194)
util.js:40
The item is updated in the db, but subsequent tries to update the item fail with the same error shown. The solution is to refresh the page. I did a clean install of keystone-5 following the docs and this happens in the starter app too.
I tracked the bug to this file in the @keystone/app-admin-ui
package. I replaced line 3:
import { useState, useEffect } from 'react';
with
import React, { useState, useEffect } from 'react';
manually in the node_modules
folder file and it fixed the bug.
To Reproduce
Steps to reproduce the behaviour:
- Clean install
npm init keystone-5-app my-app
. - Follow the steps: provide a db
connection string
, check the connection, choose a starter (this bug appears with any starter that uses the admin UI). - Update any item using the admin UI. It doesn't have to be a custom List, trying to update the initial user created by the install throws the error too.
- See error in the console.
Expected behaviour
The item should be updated and a toast message shown, success or error one depending on data inputed.
Additional context
I know Keystone 5 is in maintenance mode, but I think many people still use it and this bug makes really inconvenient working with it.
I don't have experience working with monorepos, but would be happy to send a PR if that will help fix it. Thank you!