- search data by typing a keyword, the app will show you the trending tags.
- select a trending tag, a question list will display.
- by scrolling to the bottom, the data on the next page will show up.
- a small comparison between
useState
andredux
, code is put on the master and the redux branch accordingly. - note: master branch (
useState
one) is just a beta version
- UI components:
<APP>
,<Search>
,<Question>
- State management:
input
,tagList
are recorded in<App>
byuseState
,questionList
is recorded incustomHook
- Main logic is putting in
<App>
and pass it to the children - fetches are controlled by
useEffect
and the dependencies.
- a global state which can divide into 3 parts: input search, tags, questions
- fetched are written by
redux-thunk
- state-related logic is extracted from UI components to actions, UI components only consume data.
- children components can get data directly without props drilling.
- the reducer uses current state data instead of passing it from UI components imperatively.
- separation: UI components and data are separated, UI components only focus on consuming data and rendering.
- splitting: logic is split into the related components without just cramming in
<App>
- better control of state change: by defining action types, developers can see clearly the order of actions and how the state is changing, dev-tool is also helping.