Coding Challenge: Phase 2
For my first blog during my time at the Flatiron School, I have decided to help others along the way by writing out the steps to complete the Phase 2 React code challenge. THE BANK OF FLATIRON
The First Core Deliverable
- We Create a const by using useState. We fetch transaction data from the JSON server using a GET request in the AccountContainer Component. We also place our fetch within a UseEffect with no dependencies since we want our data to be fetched once after the DOM has been rendered. We pass down transactions to the TransactionList.
2. In TransactionList we pass down our transactions prop then we render the transactions by using .map and map through our transactions. We return the new array into our Transaction child component every Transaction is given a unique key using the transactions individual id.
3. In Transaction we place our transaction characteristics in the HTML template and get our transaction to render on our page!
MAGIC !!
The Second Core Deliverable
- Since our Transaction Data state will need the new item to render it in the DOM, we switch to our AccountContainer (parent to AddTransactionForm component) and construct our addItem function to pass as a prop to our child component.
Get Tomas Makaj’s stories in your inbox
Join Medium for free to get updates from this writer.
2. Then we pass down addItem to the AddTransActionForm
2. Switch over to our AddTransactionForm, where we construct our user’s addItem state, we construct a function to continually update our state when the user types, we construct our submit function to pass our callback function in our POST request, and reset our form.
The Third Core Deliverable
- We set up a new const using useState. We create our searchFilter function and use .filter to filer the transactions in the search bar. We also create a new const for newTransactions = search filter and we pass down setSearch in search & newTransactions into transactions
2. We pass down setSearch as a prop in search. We create 2 functions one to handleClick and the other to handleString to have the search button work when we are searching transactions
Conclusion
Magic! You passed your Phase 2 React coding challenge!









