Created
January 12, 2021 17:49
-
-
Save bnayae/6ba332f3553da1caf6cf1aee0d20e036 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { useRecoilState } from 'recoil'; | |
import { stateComment, stateStars } from '../../../states'; | |
import { StarsPicker } from '../../ui-units'; | |
export const Details = () => { | |
const { id, journey } = useRoutingInfo(); // parse query string | |
const key: IRecoilId = { id, journey }; | |
// best practice (won't cause rendering of the entire component) | |
const starState = stateStars(key); | |
// bad practice (will cause rendering of the entire component) | |
const [comment, setComment] = useRecoilState(stateComment(key)); | |
return ( | |
<div> | |
<StarsPicker className="raring" state={starState} /> | |
<input | |
className="comment-input" | |
type="text" | |
value={comment} | |
onChange={(e) => setComment(e.target.value)} | |
/> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment