Skip to content
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

fix: bug #1727 #1728

Merged
merged 2 commits into from
May 24, 2023
Merged

fix: bug #1727 #1728

merged 2 commits into from
May 24, 2023

Conversation

yanCode
Copy link
Contributor

@yanCode yanCode commented May 24, 2023

the reason of this bug is the preview component is rendered as
{currentStep.value === "select" && (...)
which means as long as the value is not "select", the content inside the () are garbage collected, whenever the value becomes true, it got re-initialized, values of all states via useState will be initialized again. so it can not remember what it was before.
To fix it, only visually hide the Preview but let the component instance always be there, by doing that, it can keep these states. the code is:

style={currentStep.value !== "select" ? { display: "none" } : {}}

By the way, as the export step doesn't have any state, (aka, a readonly component), so it's fine to keep it as {currentStep.value === "preview" && ( ... )

@yanCode yanCode changed the title fix bug #1727 fix: bug #1727 May 24, 2023
@Yidadaa Yidadaa merged commit 8874c68 into ChatGPTNextWeb:main May 24, 2023
1 check passed
xuzhenjun130 pushed a commit to xuzhenjun130/ChatGPT-Next-Web that referenced this pull request May 31, 2023
gaogao1030 pushed a commit to gaogao1030/ChatGPT-Next-Web that referenced this pull request May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants