sanity-io / block-content-to-react

Deprecated in favor of @portabletext/react
https://github.com/portabletext/react-portabletext
MIT License
161 stars 25 forks source link

Invalid Hook Call when deploying Sanity #56

Closed bpyle02 closed 1 year ago

bpyle02 commented 2 years ago

I'm not sure what happened, but I was trying to get my BlockContent component to work because it isn't displaying any styles (only plain text), and now I can't deploy my sanity project! It runs fine except when I try to deploy it.

I am getting this error:

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
    at resolveDispatcher (C:/Users/Mail4/OneDrive/Documents/Programming/ReactJS Projects/my-portfolio/brandonsblog/node_modules/@sanity/base/node_modules/react/cjs/react.development.js:1476:13)    
    at useMemo (C:/Users/Mail4/OneDrive/Documents/Programming/ReactJS Projects/my-portfolio/brandonsblog/node_modules/@sanity/base/node_modules/react/cjs/react.development.js:1531:20)
    at Document (C:/Users/Mail4/OneDrive/Documents/Programming/ReactJS Projects/my-portfolio/brandonsblog/node_modules/@sanity/base/lib/components/Document.js:49:40)
    at processChild (C:/Users/Mail4/OneDrive/Documents/Programming/ReactJS Projects/my-portfolio/brandonsblog/node_modules/react-dom/cjs/react-dom-server.node.development.js:3353:14)
    at resolve (C:/Users/Mail4/OneDrive/Documents/Programming/ReactJS Projects/my-portfolio/brandonsblog/node_modules/react-dom/cjs/react-dom-server.node.development.js:3270:5)
    at ReactDOMServerRenderer.render (C:/Users/Mail4/OneDrive/Documents/Programming/ReactJS Projects/my-portfolio/brandonsblog/node_modules/react-dom/cjs/react-dom-server.node.development.js:3753:22)
    at ReactDOMServerRenderer.read (C:/Users/Mail4/OneDrive/Documents/Programming/ReactJS Projects/my-portfolio/brandonsblog/node_modules/react-dom/cjs/react-dom-server.node.development.js:3690:29)
    at Object.renderToStaticMarkup (C:/Users/Mail4/OneDrive/Documents/Programming/ReactJS Projects/my-portfolio/brandonsblog/node_modules/react-dom/cjs/react-dom-server.node.development.js:4314:27)
    at buildStaticAssets (C:/Users/Mail4/OneDrive/Documents/Programming/ReactJS Projects/my-portfolio/brandonsblog/node_modules/@sanity/core/lib/actions/build/buildStaticAssets.js:162:118)
    at async _default (C:/Users/Mail4/OneDrive/Documents/Programming/ReactJS Projects/my-portfolio/brandonsblog/node_modules/@sanity/core/lib/actions/deploy/deployAction.js:93:9)

and here is my package.json file:

{
  "name": "brandonsblog",
  "private": true,
  "version": "1.0.0",
  "description": "",
  "main": "package.json",
  "author": "Brandon Pyle <mail4brando@gmail.com>",
  "license": "UNLICENSED",
  "scripts": {
    "start": "sanity start",
    "build": "sanity build"
  },
  "keywords": [
    "sanity"
  ],
  "dependencies": {
    "@sanity/base": "^2.23.2",
    "@sanity/block-content-to-react": "^3.0.0",
    "@sanity/code-input": "^2.23.2",
    "@sanity/core": "^2.23.2",
    "@sanity/default-layout": "^2.23.1",
    "@sanity/default-login": "^2.23.1",
    "@sanity/desk-tool": "^2.23.2",
    "@sanity/vision": "^2.23.1",
    "prop-types": "^15.7",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "sanity-plugin-markdown": "^2.1.0",
    "styled-components": "^5.2.0"
  },
  "devDependencies": {},
  "repository": {
    "type": "git",
    "url": "https://github.com/bpyle02/my-portfolio-new.git"
  }
}

You can find my code here: https://github.com/bpyle02/portfolio And the live website here: https://brandonpyle.netlify.app/blog/how-to-properly-write-a-github-readme

rexxars commented 1 year ago

Closing this, as the new @portabletext/react library is the successor to this module. Please see https://github.com/portabletext/react-portabletext