- User Story
Login ဝင်ထားတဲ့ user တစ်ယောက်အနေနဲ့ article တွေကို သဘောကြကြောင်း / သဘောမကြကြောင်းဖော်ပြနိုင်ဖို့အတွက် voting ပေးချင်တယ်။
Login မဝင်ရေသးတဲ့သူက voting ပေးဖို့ နှိပ်ရင် Login ဝင်ထားမှ ပေးလို့ရမယ် ဖြစ်ကြောင်း ပြပေးပြီး Login Page ကို သွားနိုင်အောင် လုပ်ပေးထားရမယ်။
- Acceptance Criterion
UI က ဒါ upvote လုပ်ထားတာလား downvote လုပ်ထားတာလားဆိုတာကို သိသာအောင် ပြပေးထားလိုက်ရမယ်။ vote လုပ်ရင်လည်း ချက်ခြင်း reactive ဖြစ်ရမယ်။ (ဂဏန်းတွေကအစ ချက်ခြင်းပြောင်း)
ဘယ်က စကိုင်မလဲ API Integration တစ်ခုလုပ်ဖို့။
လုပ်ရမယ့် Written Guide တစ်ခုလိုတယ်။
-
State ဒါက သတ်မှတ်ထားပြီးသွားပြီ
-
UI Page လည်းရပြီ Component လည်း ရပြီ
-
UI Logic ဘယ် State ကို ဘယ်လို UI Render ချမှာလဲ လုပ်မယ်။
-
Reducers မှာ Initial State Action Thunk API Call Endpoints
- law of attractions.
ချမ်းသာချင်တယ်။ အလုပ်ကြိုးစားတယ်။
တစ်ချိန်လုံး ချမ်းသာချင်နေတဲ့စိတ်။
ကိုယ်ဘာတွေတွေးနေတာလဲကို သတိကပ်ထားရမယ်။
- money mindset
limited mindset limiting
သီချင်းမဆိုရင် ပိုက်ဆံမရဘူးဆိုတဲ့ ယုံကြည်မှု။
အမှန်က ရပေါက်ရလမ်းက ဘက်ပေါင်းစုံမှာရှိတယ်။
Thunk တွေ ရေးရမယ့် အပိုင်း။ Local business logic
စပြီး Bug ပါပြီ။ အပိုကုတ်တွေက ပြဿနာတက်။ အလွယ်တကူ ကော်ပီပေ့ခြင်းရဲ့ ဝေဒနာ။ နှစ်နာရီအကြာမှာ ရှင်းလိုက်နိုင်ပါပြီ။
- User Story
success ဖြစ်သွားရင် အခြား Page ကို ရောက်သွားမယ်။
npm install firebase
https://www.freecodecamp.org/news/use-firebase-authentication-in-a-react-app/
User Register စလုပ်မယ်။ validation လည်း လိုမယ်။
*** Need to add network error handling on home page ***
အင်တာနက် မရှိလျှင် ဆာဗာမှ အကြောင်းမပြန်လျှင်
အခြေအနေ အကျိုးအကြောင်း Home Page မှာ ပြသပြီး Refresh လုပ်နိုင်စေရန်။
ပထမဆုံး အကြိမ်ဆိုရင် -> Refresh Pagination ဆိုရင် on button scroll No Data ဆိုရင် Data မရှိတော့ကြောင်း ပြောပြီး Event Listener ပါ ပြန်ဖြုတ်ရမယ်.
** Story **
As a new user can register, I want to create a new account on the platform, so that I can access full range of services and features offered.
** Acceptance Criteria **
- Register Page ကို ရောက်တဲ့အခါ Regsiter လုပ်ဖို့အတွက် အောက်က အချက်တွေ တောင်းမယ်။
- display name
- password
- confirm password
- Register လုပ်ဖို့ ဖြည့်လိုက်တဲ့ အချက်အလက် က မစုံရင် မစုံတဲ့အကြောင်း feedback ပြရမယ်။
- Authenticated လုပ်နေစဉ် အတောအတွင်းမှာ Loading Indicator ပြရမယ်။
- Email က စနစ်ထဲမှ ာရှိပြီးသားဆိုရင် ပြောင်းဖို့ပြောရမယ်။
- အောင်မြင်တယ်ဆိုရင် နောက် page တစ်ခုကို အလိုအလျောက် ပြောင်းသွားရမယ်။
Definition of Done:
- The registration process should be tested for functionality, security, and user-friendliness.
- Relevant error messages and notifications are displayed when needed.
- The email verification system should work reliably.
- All user stories related to registration should be implemented.
- The code is reviewed and approved by a team member.
- Documentation is updated to reflect the new registration process.
It's all about thinking, foucs.
- Internal State မှာ Form Data တစ်ခုလုံးကို သိမ်းထားပြီး input onChange မှာ သက်ဆိုင်ရာ data ကို setState လုပ်ပေးထားတယ်။
- onSubmit မှာ Field တစ်ခုချင်းစီကို စစ်ပြီး error object မှာ အကြောင်းပြချက်တွေ ရေးပေးထားတယ်။
- error object မှာ ရှင်းရင် api call ခေါ်ဖို့ သက်ဆိုင်ရာ Thunk Action ကို Dispatch လုပ်
- မရှင်းရင် setState(error) လုပ်
ဒါက Local အတွက် အတော်လေးအဆင်ပြေတဲ့ ကိစ္စ။
error message ကို အရင်စစ်ရမယ်။
{
"status" : false,
"msg" : "this is message",
"data" : {},
"errors" : {
"input_name_one" : "reasons",
"input_name_two" : "reasons",
}
}
ဒါဆို errors object က remote မှာ အိုကေသွားပြီ။ တစ်ခုပဲ စောနက internal state မှာ သိမ်းထားတဲ့ Error ကို Redux Store မှာ ထည့်ပေးရမှာလား?
ဒါဆို အခု ပြဿနာက React ဘက်မှာဆိုရင် error object ကို ဘယ်မှာ ထားရမလဲ?
internal state အနေနဲ့ သုံးမလား redux store အနေနဲ့ ထားမလား?
redux store မှာ ထားမှပဲ api က ပြန်လာတာကို သိနိုင်မယ်။ internal state မှာ ထားရင် နှစ်ခု ထားရမယ်။ အလုပ်ပိုရှုပ်မယ်။ ဒါကြောင့် Redux Store မှာပဲထားလိုက်မယ်။
*** Valid ဖြစ်တဲ့အကြောင်းလည်း ပြောဖို့လိုမယ် ***
remote က error body ကို ယူဖို့ အရင်လုပ်ရမယ်။
အခုက http response code အဆင်မပြေတာနဲ့ တစ်ခါတည်း throw သွားတာ။
-
Register API Integration
-
User Profile UI
-
Update user profile UI, API
-
New Post UI, API
-
Edit Post UI, API
-
Context Menu for report, edit , delete article
-
Up Vote, Down Vote and Comment display UI in home page and detail
-
Create comment ui
-
Edit comment ui
-
Delete comment ui
-
Context menu for report , edit and delete comment
-
Deployment pipeline from cloudflare
Promise နဲ့ AsyncThunk အကြောင်း ရိပ်ဖမ်းသံဖမ်း နားလည်။
Http Error တွေကို လူလိုသူလိုနားလည်အောင် Exception Handling လုပ်ဖို့လိုမယ်။
အခု တကယ့် UI ကို ကြည့်ဖို့ လိုလာပြီ။
status နဲ့ error message ကို ကြည့်ဖို့ လိုမယ်။ Selector သုံးရမယ်။
Body ရဲ့ scroll က အောက်ဆုံးအထိ ရောက်လာရင် Pagination API ကို ခေါ်ဖို့လိုမယ်။ Body ရဲ့ scroll event ကိုလည်း ဒီ Page ကပဲ handle လုပ်သင့်တယ်။ Global မှာ မလုပ်သင့်။
စာရှည်ရင် ဖျတ်မယ်။
it's always 1
page ဆိုတဲ့ state တစ်ခု ရှိတယ်။ ui မှာ စစ်ကြည့်ရင်လည်း up to date ဖြစ်တယ်။ ဒါပေမယ့် function ထဲမှာ console.log ထုတ်ကြည့်ရင် it's alway initial value.
prev_page 0 page 1
prev_page 1 page 1 -> it's valid, make api request
prev_page 2 page 1 -> it's invalid, throw an error
Error ဖြစ်သွားရင် ပြန်လျော့ပေး
*** Article Detail *** ရပြီ။
*** Functional Component တစ်ခုရဲ့ Lifecycle ကို သိဖို့လိုလာပြီ ***
useEffect hook က ဘယ်ချိန်မှာ run မှာလဲ?
နှစ်ချိန်မှာ Run တယ်။
- After the initial render
- When dependencies change
Initial Render နဲ့ Rerender ဆိုတာ ရှိတယ်။ Component တစ်ခု စပြီး UI ပေါ်တင်ဖို့ Initial Render လုပ်တယ်။ ပြီးရင် အကြောင်းအမျိုးမျိုးနဲ့ Rerender လည်း လုပ်တယ်။
dependency changes ဖြစ်ရင် useEffect က ပြန် run မယ်မထင်ရဘူးပေါ့။ မှန်တယ်။ ReRender လုပ်တဲ့အချိန် useEffect ကို မခေါ်တော့ဘူး။
The useEffect hook in React runs after the initial render of the component and can run subsequent times based on the dependencies you specify. It allows you to perform side effects in your functional components, such as data fetching, subscriptions, or in the case of navigation, route changes. Here's when useEffect runs:
After the Initial Render: By default, the code inside the useEffect callback runs immediately after the initial render of the component. This is similar to the componentDidMount lifecycle method in class components.
When Dependencies Change: You can pass an array of dependencies as the second argument to useEffect. If any of the dependencies change between renders, the useEffect callback will run again after the component re-renders. If you pass an empty array ([]) as the second argument, the effect runs only after the initial render and doesn't have any dependencies to watch for changes.
- Login API
ဒါကို ဘယ်မှာ ရေးရမလဲ? asyncExtra ဆိုပြီး Reducer မှာ ရေးမယ်။
ဒီ action ကို Form Submit Handler က ခေါ်ပေး ( dispatch ) လုပ်မယ်။
internal state ကို loading ပြင်မယ်။ ခလုပ်ကို disabled and loading indicator ပြောင်းမယ်။
UI တော့ အိုကေပြီ။ တစ်ခုပဲ API က Result ကိုဘယ်လိုပြမလဲ?
API အရင်ရေးလိုက်ဉီးမယ်။ အခုက UI မှာ Result ပြဖို့ Logic ကို လုံးဝစဉ်းစားလို့မရ ေသး။
နောက်တစ်ခု Form Validation ကို ဘယ်လို Handle လုပ်ကြမလဲ?
- JS မှာ Promise ဆိုတာ ဘာလဲ?
- axios.post က ဘာကို Return ပြန်ပေးမှာလဲ?
- createAsyncThunk က ဘာတွေကို လက်ခံပြီး ဘယ်ချိန်မှာ pending, fulfilled စတဲ့ event တွေ ထုတ်ပေးမှာလဲ?
- .addCase(loginAsync.pending, (state) => { state.status = 'loading'; }) ဒီမှာ ဘယ်လို listen လုပ်ရမလဲ?
ဒါတွေ ပြန်ဖတ်ဖို့ လိုနေပြီ။
- List required pages
- Add ui component for each page
- Link each other
- Integrate API
- Login
- Register
- Newsfeed
- Detail
- Profile
- Edit profile
- Create article
- Edit article
** Flutter is easier than HTML,CSS
ကျွန်တော့အတွက်ကတော့ အတော်လေး ရှုပ်ထွေးတဲ့ ရေးထုံးတွေ စဖြစ်လာပါပြီ။
<Container sx={{ py: { xs: 8, lg: 16 } }}>
<Box
sx={{
mx: "auto",
mb: { lg: 16, sm: 8 },
maxWidth: "sm",
textAlign: "center",
}}
>
ဒါတွေ နားလည်ဖို့က သူ့ Library ကို အချိန်ပေးပြီး ဖတ်မှပဲဖြစ်မယ်။ မဟုတ်ရင် မရင်းနှီးတဲ့ ရေးထုံးတွေနဲ့ စိတ်ညစ်ရလိမ့်မယ်။
ဘာတစ်ခုမှကို ချရေးမထားတာလည်း ပြဿနာ ကွန်ပျူတာရှေ့ရောက်ရင် ကိုယ်လုပ်ရမယ့် အလုပ်ကို ကိုယ်မသိတော့ဘူး။ အရာရာဟာ ထွေပြားနေရော။
IDE က အထောက်အကူမပြုတာကလည်း ပြဿနာ။
- UI Kit ထဲက လိုသမျှတွေ Page အလိုက် ထည့်ထားရန်
- Internal State မှာ ရှင်းရမယ့် ကိစ္စတွေ လိုက်ရှင်းထားမယ်
- API Integration -> Register, Login, Select , Vote, Comment
ပရောဂျက်ကို ပြန်ကိုင်လိုက်ရင် ဘာလုပ်လို့ ဘာကိုင်ရမှန်းမသိ ပရောဂျက်ရဲ့ ဘယ်အပိုင်းကို ရောက်လို့ ဘာဆက်လုပ်ရမလဲ လဲမသိ အတော်ကို ယောင်ချာချာ အခြေအနေ။
ခလုပ်ကိုပဲ Loading ခလုပ်နဲ့ အစားထိုးလိုက်မယ်။
နှိပ်လိုက်ရင် Form Validation လုပ်ပြီးတာနဲ့ 5 sec စောင့်မယ်။ if နဲ့ စစ်ပြီး အခြေအနေပြမယ်။
ဘာတွေလိုမလဲ?
- login_submit_enable
Pandora ကို React-Redux-Toolkit နဲ့ ရေးရန်။ UI အနေနဲ့ Material UI ကိုသုံးပြီး State Management ကို Redux-React သုံးမယ်။
Material UI and Icons
npm install @mui/material @emotion/react @emotion/styled
npm install @mui/icons-material
Material UI နမူနာ App ကို ဒီမှာ ကြည့်လို့ရတယ်။
https://codesandbox.io/s/github/mui/material-ui/tree/master/examples/material-ui-cra
Screen Flow ကို ပြန်ကြည့်ပြီး Route နဲ့ သက်ဆိုင်ရာ Page တွေ Navigation တွေ မှန်အောင် အရင်လုပ်ရမယ်။
State Management အပိုင်းက အတော်လေး ရိုးရှင်းတယ်။
dispatch နဲ့ selector hook တွေသုံးပြီးအလုပ်လုပ်ရုံပဲ။ UI ကိုပဲ smooth ဖြစ်အောင် ဂရုစိုက်ရမယ်။
Routing အတွက်
npm install react-router-dom localforage match-sorter sort-by
git rm -r --cached node_modules ;
git rm -r --cached build ; git status
This project was bootstrapped with Create React App, using the Redux and Redux Toolkit template.
In the project directory, you can run:
######### npm start
Runs the app in the development mode.
Open http://localhost:3000 to view it in your browser.
The page will reload when you make changes.
You may also see any lint errors in the console.
######### npm test
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
######### npm run build
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
######### npm run eject
Note: this is a one-way operation. Once you eject
, you can't go back!
If you aren't satisfied with the build tool and configuration choices, you can eject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject
will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use eject
. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.