Skip to content

dbeaver/pro#8333 fix: Eliminate React 19 error in useEditorDefaultExtensions#4381

Open
SychevAndrey wants to merge 1 commit into
develfrom
8333-cb-eliminate-react-19-error-in-useeditordefaultextensions
Open

dbeaver/pro#8333 fix: Eliminate React 19 error in useEditorDefaultExtensions#4381
SychevAndrey wants to merge 1 commit into
develfrom
8333-cb-eliminate-react-19-error-in-useeditordefaultextensions

Conversation

@SychevAndrey

Copy link
Copy Markdown
Contributor

replace useRef with useState for managing editor options state

…ensions

replace useRef with useState for managing editor options state
@SychevAndrey SychevAndrey self-assigned this Jun 4, 2026
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 complexity

Metric Results
Complexity 4

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

extensions.current = createExtensions(options);
if (!isObjectsEqual(options, state.options)) {
const result = createExtensions(options);
setState({ options, result });

@devnaumov devnaumov Jun 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will cause extra rerenders, its better to comment such code parts as expected than fix it this way

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how many? how will it affect the product?

@devnaumov devnaumov Jun 5, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Props are changed -> rerender, then if options are different, you are setting state that rerenders one more time and its just a bad react practice. You are executing state update from component body to sync state from props, it might cause infinite rerenders and other problems. I think that the prev approach is cleaner and less buggy. If we know what we are doing, we dont need to fix it. I suggest to disable this eslint rule as this pattern is commonly used across react ecosystem, what do you think?

extensions.current = createExtensions(options);
if (!isObjectsEqual(options, state.options)) {
const result = createExtensions(options);
setState({ options, result });

@devnaumov devnaumov Jun 5, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Props are changed -> rerender, then if options are different, you are setting state that rerenders one more time and its just a bad react practice. You are executing state update from component body to sync state from props, it might cause infinite rerenders and other problems. I think that the prev approach is cleaner and less buggy. If we know what we are doing, we dont need to fix it. I suggest to disable this eslint rule as this pattern is commonly used across react ecosystem, what do you think?

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 this pull request may close these issues.

3 participants