-
Notifications
You must be signed in to change notification settings - Fork 734
FeatureHighlight - migrate to new api, remove unsafe method #1290
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
Changes from 4 commits
1f2be57
05d0d32
f04e4b6
34aaae8
7d56142
214ae80
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 |
---|---|---|
|
@@ -148,11 +148,19 @@ class FeatureHighlight extends BaseComponent { | |
this.setTargetPosition(); | ||
} | ||
|
||
UNSAFE_componentWillReceiveProps(nextProps) { | ||
this.setTargetPosition(nextProps); | ||
static getDerivedStateFromProps(nextProps, prevState) { | ||
const target = nextProps?.getTarget?.(); | ||
const node = FeatureHighlight.findTargetNode(target); | ||
if (node && node !== prevState?.node) { | ||
return {...prevState, node}; | ||
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. Why setting all '...prevState' and not only 'node'? What else has changed? 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.
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. Once a prop changed and 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. Got it, thanks! |
||
} | ||
return null; | ||
} | ||
|
||
componentDidUpdate() { | ||
componentDidUpdate(nextProps) { | ||
if (!_.isEqual(nextProps, this.props)) { | ||
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. Is it really necessary to check all the props? All of them are relevant for setting the target position? 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. Right, fixed |
||
this.setTargetPosition(); | ||
} | ||
if (this.viewRef) { | ||
this.setAccessibilityFocus(this.viewRef); | ||
} | ||
|
@@ -163,7 +171,7 @@ class FeatureHighlight extends BaseComponent { | |
AccessibilityInfo.setAccessibilityFocus(reactTag); | ||
} | ||
|
||
findTargetNode(target) { | ||
static findTargetNode(target) { | ||
Inbal-Tish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return findNodeHandle(target); | ||
} | ||
|
||
|
@@ -181,9 +189,6 @@ class FeatureHighlight extends BaseComponent { | |
setTargetPosition(props = this.props) { | ||
if (props.getTarget !== undefined) { | ||
const target = props.getTarget(); | ||
|
||
const node = this.findTargetNode(target); | ||
this.setState({node}); | ||
if (target) { | ||
setTimeout(() => { | ||
target.measureInWindow((x, y, width, height) => { | ||
|
Uh oh!
There was an error while loading. Please reload this page.