-
Notifications
You must be signed in to change notification settings - Fork 0
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
Hooks version #18
Hooks version #18
Conversation
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.
Dude good separation of concerns. Definitely thoughtful code.
this.setState({ | ||
error: false, | ||
}); | ||
const withErrorHandler = (WarppedComponent, axios) => 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.
I like the dependency injection of axios
I'm curious what inspired you to pass it in like that.
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.
It is just way listing to Axios call before reach then, catch
AKA global error handler
mounted.current = true; | ||
return () => { | ||
axios.interceptors.request.eject(axiosRequest); | ||
axios.interceptors.response.eject(axiosResponse); |
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.
Damn this is some advanced axios API moves -- neat!
For some reason, GitHub action -- the build failed to Webpack console warns @leggomuhgreggo keep that in mind |
Hope this PR satisfy you I did my best to mack it optimal |
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.
Solid work!
I felt bad or taking so long to review so I was pretty thorough, but hope it doesn't give the wrong impression -- the changes are dank 👍
There might be one or two spots where you could eliminate a hook if the code organized a little different but still totally works.
LMK if you have any questions 👍
'prettier/react', | ||
'plugin:jsx-a11y/recommended', | ||
'plugin:react-redux/recommended', | ||
'plugin:jest/recommended', | ||
'plugin:jest/style' | ||
'plugin:jest/style', | ||
'plugin:prettier/recommended', |
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.
Note (no change required): One thing about the prettier plugin is that -- if some other plugin has formatting rules that conflict with prettier -- whichever plugin is later in the extends: [...]
array will override the other. So keeping prettier near the last is a good practice 👍
<main className={classes.Content}>{children}</main> | ||
</> | ||
); | ||
}; |
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.
👍
valid: false, | ||
touched: false, | ||
}, | ||
}); |
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.
suggestion: I'd recommend extracting initial state -- keeping config separate is going to make life easier
authError, | ||
authenticated, | ||
authRedirect, | ||
buildingBurger, |
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.
suggestion (non-blocking): This is slightly out of scope but -- it's good practice to observe the boolean naming convention where you prefix boolean vars with simple verbs like "is" "has" "can" etc.
Incidentally, your naming choices are really solid -- like way better than most of the code I see 👍
if (buildingBurger) { | ||
authSetRedirectPath('/checkout'); | ||
} else { | ||
authSetRedirectPath('/'); | ||
} | ||
} | ||
}, [buildingBurger]); |
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.
👍
|
||
updatePurchaseState = () => { | ||
const { ingredients } = this.props; | ||
const updatePurchaseState = useCallback(() => { |
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 disabledInfo = { | ||
}, [ingredients]); | ||
|
||
let orderSummary = null; |
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.
question: Is this state?
}, [ingredients]); | ||
|
||
let orderSummary = null; | ||
let burger = <Spinner />; |
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.
suggestion: might try to rewrite this as a ternary either inline or an extracted render method -- that way you can skip the mutation.
orderSummary = ( | ||
<OrderSummary | ||
ingredients={ingredients} | ||
}, [ingredients]); |
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.
suggestion: Interesting! Hmm might be a slightly indirect control flow mechanism but totally works
for (const key in disabledInfo) { | ||
if ({}.hasOwnProperty.call(disabledInfo, key)) { | ||
disabledInfo[key] = disabledInfo[key] <= 0; | ||
} | ||
} |
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.
nitpick: I'd try to avoid for loops if possible since it's usually a sing of mutation and the syntax is a little gnarly. Also curious what inspired the hasOwnProperty
approach?
Trying to figure out Hooks & apply it to the core project