-
-
Notifications
You must be signed in to change notification settings - Fork 8
Update react-dom peerDependencies to match react (17/18/19) #37
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
3cce32f
280ce65
f8ed216
b3f06f7
d1bbf16
8858035
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import * as React from 'react' | ||
| import ReactDOM from 'react-dom' | ||
| import { Field } from 'react-final-form' | ||
| import { Html5ValidationFieldProps } from './types' | ||
| import warning from './warning' | ||
|
|
@@ -24,6 +23,7 @@ interface WithValidity { | |
|
|
||
| class Html5ValidationField extends React.Component<Html5ValidationFieldProps> { | ||
| private input: WithValidity | null = null | ||
| private rootRef = React.createRef<HTMLElement>() | ||
|
|
||
| static defaultProps = { | ||
| badInput: 'Incorrect input', | ||
|
|
@@ -42,7 +42,7 @@ class Html5ValidationField extends React.Component<Html5ValidationFieldProps> { | |
| } | ||
|
|
||
| componentDidMount(): void { | ||
| const root = ReactDOM.findDOMNode(this) | ||
| const root = this.rootRef.current | ||
| if (root) { | ||
| let input: WithValidity | null = null | ||
| if (/input|textarea|select/.test(root.nodeName.toLowerCase())) { | ||
|
|
@@ -137,10 +137,22 @@ class Html5ValidationField extends React.Component<Html5ValidationFieldProps> { | |
| ...fieldProps | ||
| } = rest | ||
|
|
||
| // Merge innerRef with rootRef for internal use | ||
| const mergedRef = (node: HTMLElement | null) => { | ||
| // Set internal ref | ||
| (this.rootRef as React.MutableRefObject<HTMLElement | null>).current = node | ||
| // Call innerRef if provided | ||
| if (typeof innerRef === 'function') { | ||
| innerRef(node) | ||
| } else if (innerRef) { | ||
| (innerRef as React.MutableRefObject<HTMLElement | null>).current = node | ||
| } | ||
| } | ||
|
Comment on lines
+148
to
+156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because Promote ♻️ Proposed refactor class Html5ValidationField extends React.Component<Html5ValidationFieldProps> {
private input: WithValidity | null = null
private fieldRef = React.createRef<HTMLElement | null>()
+
+ private mergedRef = (node: HTMLElement | null): void => {
+ ;(this.fieldRef as React.MutableRefObject<HTMLElement | null>).current = node
+ const { innerRef } = this.props
+ if (typeof innerRef === 'function') {
+ innerRef(node)
+ } else if (innerRef) {
+ ;(innerRef as React.MutableRefObject<HTMLElement | null>).current = node
+ }
+ }
@@
- // Merge innerRef with fieldRef
- const mergedRef = (node: HTMLElement | null) => {
- ;(this.fieldRef as React.MutableRefObject<HTMLElement | null>).current =
- node
- if (typeof innerRef === 'function') {
- innerRef(node)
- } else if (innerRef) {
- ;(innerRef as React.MutableRefObject<HTMLElement | null>).current = node
- }
- }
+ const mergedRef = this.mergedRef🤖 Prompt for AI Agents |
||
|
|
||
| return React.createElement(Field, { | ||
| ...fieldProps, | ||
| validate: this.validate, | ||
| ref: innerRef as React.Ref<HTMLElement>, | ||
| ref: mergedRef, | ||
| component: 'input' | ||
| }) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.