-
Notifications
You must be signed in to change notification settings - Fork 67
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
CPLAT-8040 Implement/Expose useRef Hook #245
Conversation
# Conflicts: # example/test/function_component_test.dart # lib/hooks.dart # lib/react_client/react_interop.dart # test/hooks_test.dart
# Conflicts: # example/test/function_component_test.dart # lib/hooks.dart # lib/react_client/react_interop.dart # test/hooks_test.dart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple comments, mostly on generics, but otherwise this looks perfect. Awesome tests!
lib/hooks.dart
Outdated
/// final input = useState(''); | ||
/// final inputRef = useRef(); | ||
/// final prevInputRef = useRef(); | ||
/// final prevInput = prevInputRef.current; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables are named pretty similarly, which makes it a little hard to tell what's going on. I think further distinguishing them and also adding some typing to the refs would help:
final inputValue = useState('');
final inputRef = useRef<InputElement>();
final prevInputValueRef = useRef<String>();
useEffect(() {
prevInputValueRef.current = inputValue.value;
});
return react.Fragment({}, [
react.p({}, ['Current Input: ${inputValue.value}, Previous Input: ${prevInputValueRef.current}']),
react.input({'ref': inputRef}),
react.button({'onClick': (_) => inputValue.set(inputRef.current.value)}, ['Update']),
]);
Looks like there are merge conflicts on this one now too after merging another PR 😅 |
# Conflicts: # example/test/function_component_test.dart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+10
Motivation
Support useRef hook in
react-dart
.Changes
useRef
function.initUseRef
constructor to theRef
object.current
property ofRef
.Please review: @kealjones-wk @aaronlademann-wf @greglittlefield-wf @joebingham-wk