-
Notifications
You must be signed in to change notification settings - Fork 66
Added fetching data to setup initialOptions. Refactored server. refs #94 #121
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?
Conversation
…host, replaced body parser with express
|
I'm sorry, I probably messed up this pull request with commits but I'm totally new to pull requests. |
|
Hi there @adam-p-git! Second, I didn't see any mistake on your commits, they all look great to me. Separated commits for refactor and feature, good message linked to the issue and PR. Awesome.! I'll take a look at the code asap and will give some feedback here. Thanks a lot for your contribution. PS - I invited you to be a team member of the project. Have you received the invite? |
|
Thanks a lot, Tiago! |
tiagostutz
left a comment
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.
Checking your code I'm thinking about changing one thing on the architecture... instead of having the "model" approach, for example in the app/src/routes/useChoiceBoardModel.ts, we could move the state that is in there ([selectedItems, setSelectedItems]) to the componente itself, ChoiceBoard.ts.
This way, the ChoiceBoard.ts would have the state and would have the reference to useOptions().
What do you think?
|
|
||
| // fetches options and return only choices | ||
| const getOptions = async () => { | ||
| const { data } = await axios({ |
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.
Why not use the more "native" fetch instead of axios to make the requests? Any thoughts?
I'm asking it because every package we add to the project increases the bundle size.
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.
Oh, I'm just used to axios, but sure, I can rewrite this with fetch. Keeping bundle size as small as possible makes sense
| var app = express(); | ||
| app.use(bodyParser.json()); | ||
| app.use( | ||
| cors({ |
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.
Nice!
I'm not sure if I understand this correctly, so please correct me if I'm mistaken. The idea is to move all state into |
|
Exactly that, @adam-p-git ! Perfect. |
|
Oh, great. That was actually what I did in my other project but in javascript. I'll probably have more questions about the app, but I will take a closer look at it tomorrow. |
Configured cors, so that app can connect to mock api.
Deleted body-parser due to supporting its features by express from 4.16.
Added new hook useOptions to fetch data from server using react-query.
Added types for options.