feat: RSS-SE-12 implement json to yaml conversion - #10
FierceSloth merged 11 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| export function SwaggerEditor({ value, onChange, format }: IProps) { | ||
| export function SwaggerEditor({ value: externalValue, onChange }: IProps) { | ||
| const [currentFormat, setCurrentFormat] = useState<DetectedFormat>('yaml'); | ||
| const [localValue, setLocalValue] = useState(externalValue || ''); |
There was a problem hiding this comment.
Potential issue. Right now the editor value is duplicated: it lives both in the value prop and in the local localValue state. For example: the parent passes value = 20, we copy it once into localValue, then the child updates localValue = 21, and later the parent resets the prop to 5, but the local state stays 21, because useState does not re-initialize when props change. In React it’s better to have a single source of truth for one piece of data
There was a problem hiding this comment.
Thank you for pointing that out. I’m aware of this error, but I’ve decided to leave it as it is for now and fix it in the RSS-SE-16 card when I’m laying out the main page; that’s when I’ll move the entire state up a level, and there won’t be a local state.
📋 Trello Task ID
⚡️ Summary
🛠 Type of change
feat(New feature)fix(Bug fix)refactor(Code improvement / Refactoring without changing logic)style(Formatting, CSS)docs(Documentation)chore(Configs, Build)test(Testing)📷 Screenshots / GIFs