Redocly / Redocly/redoc

Unable to build docs with 2.x (`Cannot read properties of null`)

Open
#2,711 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
TypeScript
Stars
25.9k
Forks
2.4k
Avg merge
13h 10m
Merged PRs (30d)
4

Description

Describe the bug

After updating @redocly/cli from 1.34.4 to 2.0.2 I'm unable to build API documentation

To Reproduce
Steps to reproduce the behavior:

  1. Run this command: npx redocly build-docs openapi.yaml
  2. See error
    Prerendering docs
    Warning: 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.
    TypeError: Cannot read properties of null (reading 'useRef')
    

Expected behavior

Redocly 2.0.2 should build documentation, just like 1.34.4 does

OpenAPI description

I'm aware that this issue may be related to the specific openapi.yaml file, however I'd prefer to not share it

Redocly Version(s)

2.0.2

Node.js Version(s)

22.15.0

OS, environment

Windows

Additional context

None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing npx redocly build-docs openapi.yaml with Redocly 2.0.2 and compare it with 1.34.4 using an available OpenAPI description. Investigate the prerendering step and the reported React useRef failure, then confirm that the same documentation build completes successfully without the invalid-hook warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, openapi, react
Domain
api, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.