-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
Migrating to const/let and Object Spread in more places #11535
Conversation
raphamorim
commented
Nov 12, 2017
•
edited
Loading
edited
- Use const/let in more places (Use const/let in more places #11467)
- Replace Object.assign by Object Spread
fe1a6e7
to
669a157
Compare
@@ -401,7 +401,7 @@ if (__DEV__) { | |||
return null; | |||
}; | |||
|
|||
var didWarn = {}; | |||
let didWarn = {}; |
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.
This can probably be a const
, since it's never re-assigned.
var ancestorInfo = Object.assign({}, oldInfo || emptyAncestorInfo); | ||
var info = {tag: tag, instance: instance}; | ||
const updatedAncestorInfo = function(oldInfo, tag, instance) { | ||
let ancestorInfo = {...{}, ...(oldInfo || emptyAncestorInfo)}; |
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.
Don't think you need ...{}
@@ -26,7 +26,7 @@ if (__DEV__) { | |||
// first, causing a confusing mess. | |||
|
|||
// https://html.spec.whatwg.org/multipage/syntax.html#special | |||
var specialTags = [ | |||
let specialTags = [ |
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.
const?
@@ -86,14 +89,13 @@ export function initWrapperState(element: Element, props: Object) { | |||
} | |||
} | |||
|
|||
var value = props.value; | |||
var initialValue = value; | |||
let initialValue = props.value; |
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.
Hmm, wonder why it was written the other way initially. 😛
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.
te-hehe
Do you recommend putting it back?
I think it does not make sense to keep this line. Since it is the same reference.
Tradeoff: I guess it was written for better readability.
What do you think @clemmy
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.
I think this is probably fine.
}); | ||
const hostProps = { | ||
...props, | ||
...{ |
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.
How about:
const hostProps = {
...props,
value: undefined,
defaultValue: undefined,
children: '' + node._wrapperState.initialValue,
};
var hostProps = Object.assign({children: undefined}, props); | ||
|
||
var content = flattenChildren(props.children); | ||
const hostProps = {...{children: undefined}, ...props}; |
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.
Similar:
const hostProps = {children: undefined, ...props};
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.
Let me know if the comments I made make sense. :)
* Convert ReactDOMFiberTextarea to const/let * Convert ReactDOMSelection to const/let * Convert setTextContent to const/let * Convert validateDOMNesting to const/let
* Convert ReactDOMFiberOption to Object Spread * Convert ReactDOMFiberTextarea to Object Spread * Convert validateDOMNesting to Object Spread
Makes a lot of sense :D |
* Use const/let in more places (facebook#11467) * Convert ReactDOMFiberTextarea to const/let * Convert ReactDOMSelection to const/let * Convert setTextContent to const/let * Convert validateDOMNesting to const/let * Replace Object.assign by Object Spread * Convert ReactDOMFiberOption to Object Spread * Convert ReactDOMFiberTextarea to Object Spread * Convert validateDOMNesting to Object Spread