A component-based implementation in JS with no external libraries apart from Jasmine. Built for discussion with software development students.
$ git clone [email protected]:dearshrewdwit/demo-news-summary.git && cd demo-news-summary
$ open index.html
NB: each component is tested in isolation. Tests stub fetch
appropriately.
$ open test/specRunner.html
When loading in the browser locally however, be careful not to send frequent requests to the API in order to avoid exceeding the request rate limit.
Each component extends the Component
class and therefore has the following interface:
- sets the component props and state
- creates the component element
- finally calls a
setupComponent()
function. This function makes any calls necessary and finishes by callingrender()
. Sometimes this might happen more than once.
- Wraps
setState()
andrender()
. Prefer using this function directly rather than the individual functions.
- updates the component
state
object with the arg object property and values.
- This function is responsible for updating the DOM with the component html.