-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
frontend login #87
frontend login #87
Conversation
619c4ed
to
288fd7a
Compare
483c9e1
to
ca20fdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
關於圖片沒能立即更新,因為React 有批次更新State的機制來提升效能,所以在同一個函式內使用一個setStateA帶入另一個StateB的話,在setStateA中值StateB仍是這次函式執行更新前值
setPortraitIndex()中的portraitChangeCount還是執行setPortraitChangeCount(portraitChangeCount + 1)前的值
可以改成:
setPortraitChangeCount(prevCount => prevCount + 1);
setPortraitIndex(prevIndex => (prevIndex + 1) % portraits.length);
也許也還有其他作法!><
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我切版時忘記在更換圖片那邊加滑鼠變成按鈕><
可以加個css:
className='login_change' onClick={changeImage}
在_login.scss加入:
&_change{
cursor: pointer;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有幾個地方div變成dev啦XD
const changeImage = () => {
const newChangeCount = portraitChangeCount + 1
const newIndex = newChangeCount % portraits.length
setPortraitChangeCount(newChangeCount)
setPortraitIndex(newIndex)
} 或是用 const portraitChangeCount = useRef(0)
const [portraitIndex, setPortraitIndex] = useState(0)
const changeImage = () => {
portraitChangeCount.current++
setPortraitIndex(portraitChangeCount.current % portraits.length)
} |
5f3fcd2
to
bbe8455
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
bbe8455
to
558e692
Compare
resolves #74