-
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/create room #98
Conversation
<Routes> | ||
<Route path='/' element={<Navigate to='/rooms' />} /> | ||
<Route path='/rooms' element={<RoomList />} /> | ||
<Route path='/game:roomId' element={<Game />} /> |
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.
game的路徑應該是path='/game/:roomId'
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.
另外webpack的output要幫我多加publicPath: '/'
,不然如果路徑有兩個以上的slash會有問題
output: {
path: path.resolve(__dirname, 'build'),
filename: isProduction ? 'js/bundle.[chunkhash].js' : 'js/bundle.js',
chunkFilename: isProduction ? 'js/[id].[chunkhash].js' : 'js/[name].js',
+ publicPath: '/'
}
// eslint-disable-next-line object-shorthand | ||
userName: userName, | ||
// eslint-disable-next-line object-shorthand | ||
userImage: userImage |
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.
這裡物件的object-shorthand可以直接簡化成
{
userName,
userImage
}
eslint的disable就可以刪掉了
onClick={() => { | ||
showModal() | ||
}} | ||
> |
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.
onClick
裡面的callback函式如果沒有要傳特定的值進去,直接傳入函式名稱就好了:
onClick={showModal}
效果是一樣的
isErrorVisible={isErrorVisible} | ||
onClose={() => setIsErrorVisible(false)} | ||
errorText={errorText} | ||
></ErrorModal> |
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.
我覺得這裡Modal的組件可以再簡化一下,甚至拆解成可以靈活更動的組件。
例如可以把Modal大致劃分為header、body、footer的區塊,每個區塊可以自由傳入自定義的children,可以根據每次不同的需求客製化,這樣同樣的Modal組件可以重複使用,就不用特地做成兩個。
建議可以去參考antd或MUI等元件庫的寫法,對以後自製元件會很有幫助。
我自己做的Modal大概會長下面這樣:
<Modal
open={true}
title={<div>title</div>}
footer={<button>確認</button>} // footer的children
>
<div>this is body</div>
</Modal>
// 沒有children的話,不需要close tag
<Modal open={true}/>
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.
哦哦哦這樣彈性很多!謝謝!!!我再修改看看
resolves #42