Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditGuesser is broken #5755

Closed
maaarghk opened this issue Jan 9, 2021 · 0 comments · Fixed by #5756
Closed

EditGuesser is broken #5755

maaarghk opened this issue Jan 9, 2021 · 0 comments · Fixed by #5756

Comments

@maaarghk
Copy link
Contributor

maaarghk commented Jan 9, 2021

When trying to follow the tutorial, EditGuesser throws the following error:

TypeError: Cannot read property 'resource' of undefined
useResourceContext in node_modules/ra-core/esm/core/useResourceContext.js:40
  37 |  */
  38 | export var useResourceContext = function (props) {
  39 |     var context = useContext(ResourceContext);
> 40 |     return props.resource || context;
  41 | };
  42 | 

EditViewGuesser in node_modules/ra-ui-materialui/esm/detail/EditGuesser.js:19
  16 | import { EditView } from './EditView';
  17 | import editFieldTypes from './editFieldTypes';
  18 | var EditViewGuesser = function (props) {
> 19 |     var resource = useResourceContext();
  20 |     var record = useEditContext().record;
  21 |     var _a = useState(null), inferredChild = _a[0], setInferredChild = _a[1];
  22 |     useEffect(function () {


I notice that EditGuesser was recently changed in #5728. In this commit, useResourceContext was also changed for props to be checked before props.resource is checked - i.e. props is made optional.

However, when merging #5730 the conflict was resolved improperly and useResourceContext is back to having props as required.

maaarghk added a commit to maaarghk/react-admin that referenced this issue Jan 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant