65 | );
66 | }
67 |
68 | export default GitHubUser;
69 |
--------------------------------------------------------------------------------
/src/hooks/useCountDown.js:
--------------------------------------------------------------------------------
1 | // TODO: example and test
2 | import { useCallback } from 'react';
3 |
4 | import useBoolean from './useBoolean';
5 | import useCounter from './useCounter';
6 | import useInterval from './useInterval';
7 |
8 | function useCountdown(countdownOption) {
9 | let countStart, intervalMs, isIncrement, countStop;
10 |
11 | if ('seconds' in countdownOption) {
12 | console.warn('error');
13 |
14 | countStart = countdownOption.seconds;
15 | intervalMs = countdownOption.interval;
16 | isIncrement = countdownOption.isIncrement;
17 | } else {
18 | // eslint-disable-next-line @typescript-eslint/no-extra-semi
19 | ({ countStart, intervalMs, isIncrement, countStop } = countdownOption);
20 | }
21 |
22 | // default values
23 | intervalMs = intervalMs ?? 1000;
24 | isIncrement = isIncrement ?? false;
25 | countStop = countStop ?? 0;
26 |
27 | const {
28 | count,
29 | increment,
30 | decrement,
31 | reset: resetCounter,
32 | } = useCounter(countStart);
33 |
34 | /**
35 | * Note: used to control the useInterval
36 | * running: If true, the interval is running
37 | * start: Should set running true to trigger interval
38 | * stop: Should set running false to remove interval
39 | */
40 | const {
41 | value: isCountdownRunning,
42 | setTrue: startCountdown,
43 | setFalse: stopCountdown,
44 | } = useBoolean(false);
45 |
46 | /**
47 | * Will set running false and reset the seconds to initial value
48 | */
49 | const resetCountdown = () => {
50 | stopCountdown();
51 | resetCounter();
52 | };
53 |
54 | const countdownCallback = useCallback(() => {
55 | if (count === countStop) {
56 | stopCountdown();
57 | return;
58 | }
59 |
60 | if (isIncrement) {
61 | increment();
62 | } else {
63 | decrement();
64 | }
65 | }, [count, countStop, decrement, increment, isIncrement, stopCountdown]);
66 |
67 | useInterval(countdownCallback, isCountdownRunning ? intervalMs : null);
68 |
69 | return [
70 | count,
71 | {
72 | startCountdown,
73 | stopCountdown,
74 | resetCountdown,
75 | },
76 | ];
77 | }
78 |
79 | export default useCountdown;
80 |
--------------------------------------------------------------------------------
/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## AltSchoolers Frontend Engineering React live class
2 |
3 | Catch the update of live classes by the instructors [Mr Oluwasetemi](https://github.com/Oluwasetemi) and [Mr Desmond](https://github.com/nyamador/) on this Repo and the available links shared in class
4 |
5 | ###### Month 1 Week 1:
6 | Introduction to React. LMS contd class
7 | During the Introductory lectures to React [Mr Oluwasetemi](https://github.com/Oluwasetemi) break down how bundling of basic javascript app works before the team at facebook created the React, and he delves a little into webpack
8 | [Webpack](https://webpack.js.org/)
9 |
10 |
11 | on the introductiory class, he also mentioned importing, exporting and using our bundled app
12 | [link to the doc he shared here](https://javascript.info/import-export)
13 |
14 | ###### Month 1 Week 2:
15 | ###### Installing create-react-app
16 |
17 | This class focuses us on installing and creating react app on our local machine
18 | [link to create react app](https://create-react-app.dev/)
19 |
20 | as the class proceeds he explain creating components in react, Writing markup with JSX in React. which is just plain javascript and html in react, Importing and Exporting Components, Passing props to a components, Conditional rendering he makes further code examples writting basic jsx elements and rendering them in our react app
21 |
22 | > He further explain the concept of component and how react is component based library for UI rendering
23 | [view class here](#)
24 |
25 | ###### Month 1 Week 3:
26 |
27 | as the classes proceeds he breaks down the concept of states and using states in React, as continuation of the classes on the schol LMS documentation guide below
28 | [States and managing state in React](https://beta.reactjs.org/learn/managing-state)
29 | [Getting started with state](https://reactjs.org/docs/state-and-lifecycle.html)
30 |
31 | ###### some self assesment questions from the instructor posted on frontend engineering slack channel
32 |
33 | 
34 |
35 | ###### Month 1 Week 4:
36 | ###### Hooks in React
37 |
38 | [Mr Desmond](https://github.com/nyamador/) and [Mr Oluwasetemi](https://github.com/Oluwasetemi) further use a little counter game of incrementing and decremeting to explain some basic react concepts, which includes the useState hook, useEffect and so on, docs below for further explanation
39 | [useEffect Hook](https://reactjs.org/docs/hooks-effect.html)
40 |
41 | [Mr Setemi](https://github.com/Oluwasetemi) contd to focuses on creating and using custom hooks in react with code examples
42 | [find code here](https://replit.com/@Oluwasetemi/understanding-usefetch?v=1#src/App.jsx)
43 |
44 | ###### Month 2 Week 1:
45 | ###### Hooks contd
46 |
47 | Further classes focus on React router dom, React router dom as a third party library for rounting pages in our React Application. It was explained deeply with examples by the instructor @oluwasetemi, he touches installing the library itself in our app using ```npm install react-router-dom which download other dependencies for us
48 | He went further to explain importing and using with the elements that are provided to us by the library, such as , ,
49 |
50 | [The doc he was using in class](https://reactrouter.com/en/main)
51 |
52 | **he further hooks provided by the third party router**
53 | He explained with code example the following
54 | - useLocation
55 | - useParams
56 | - useNavigate
57 | - useOutlet
58 |
59 | [view code here](https://stackblitz.com/edit/vitejs-vite-hswavt?file=src%2FApp.jsx)
60 | [further link](https://replit.com/@Oluwasetemi/understanding-usefetch?v=1#src/App.jsx)
61 |
62 | further link he shared, Input valid github account name
63 | [see here](https://stackblitz.com/edit/vitejs-vite-fdk26g?file=src%2FApp.jsx)
64 |
65 |
66 | **further explanations he made in the last class includes **
67 | - composition vs inheritance using `props.children` and managing layouts in our Application-
68 |
69 | [find doc and code examples here](https://reactjs.org/docs/composition-vs-inheritance.html)
70 |
71 |
72 | ###### Getting Started with this Repo
73 |
74 | Fork the project to a new repositery
75 | clone the repo on your terminal
76 |
77 | cd to the project directory
78 | `code .` to open in your vscode
79 |
80 | ```
81 | yarn start or
82 | `npm start` to run the app on your local
83 | ```
84 |
85 | navigate to [localhost:3000](http://localhost:3000) on your browser.
86 |
87 |
88 | This project was bootstrapped with [create react app](https://github.com/facebook/create-react-app).
89 |
90 |
--------------------------------------------------------------------------------