6 kyu

PC upgrade specs using HOC in ReactJS

Description:

First steps to learning the basics of higher order components (HOC) in ReactJS

A HOC is a function that takes a component as the first parameter and returns a function wrapping the first parameter.

function withExample(Component) {
  return function(props) {
    return <Component />
  }
}

More about HOC: ReactJS docs.

If you complete this kata try Truncate paragraph using HOC in React JS.

Challenge

You're building a new feature on your e-commerce site which displays two computer specs - basic and pro.

The PcDisplay component is already built and expects 5 props. { title, price, cpu, ram, ssd }

You will need to build a withPriceModel HOC and using that to manage the price of the BasicModel and ProModel components.

  • Build a HOC called withPriceModel which takes the PcDisplay component for first param and price increase number for the second param.

  • withPriceModel will manage the price and must set a default price of 50.

  • BasicModel should use the default price set by withPriceModel

  • ProModel should use withPriceModel to increase the price by 60. Total price should be 110.

  • Since the withPriceModel is responsible for managing the price, ensure that it can't be overritten by passing in a price prop.

React
Fundamentals

Stats:

CreatedMar 4, 2018
PublishedMar 6, 2018
Warriors Trained1162
Total Skips40
Total Code Submissions2153
Total Times Completed523
JavaScript Completions523
Total Stars37
% of votes with a positive feedback rating89% of 80
Total "Very Satisfied" Votes66
Total "Somewhat Satisfied" Votes11
Total "Not Satisfied" Votes3
Total Rank Assessments5
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • richkotze Avatar
  • Voile Avatar
Ad