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

steroids/dev#578 Сделать логику сохранения элементов дерево в local storage #316

Merged
merged 10 commits into from
Feb 2, 2024

Conversation

NicolaAK
Copy link
Contributor

No description provided.

@NicolaAK NicolaAK requested a review from fogarea January 12, 2024 08:15
@NicolaAK NicolaAK self-assigned this Jan 12, 2024
src/hooks/useTree.ts Outdated Show resolved Hide resolved
src/hooks/useTree.ts Outdated Show resolved Hide resolved
src/hooks/useTree.ts Outdated Show resolved Hide resolved
src/hooks/useTree.ts Outdated Show resolved Hide resolved
src/hooks/useTree.ts Outdated Show resolved Hide resolved
src/ui/nav/Tree/Tree.tsx Outdated Show resolved Hide resolved
src/ui/nav/Tree/Tree.tsx Outdated Show resolved Hide resolved
src/hooks/useTree.ts Outdated Show resolved Hide resolved
@fogarea fogarea marked this pull request as draft January 12, 2024 11:49
@NicolaAK NicolaAK marked this pull request as ready for review January 12, 2024 12:22
@NicolaAK NicolaAK requested a review from fogarea January 12, 2024 12:22
src/hooks/useTree.ts Outdated Show resolved Hide resolved
src/hooks/useTree.ts Outdated Show resolved Hide resolved
src/hooks/useTree.ts Outdated Show resolved Hide resolved
src/hooks/useTree.ts Outdated Show resolved Hide resolved
src/ui/nav/Tree/Tree.tsx Show resolved Hide resolved
@Daria-Kuzminykh Daria-Kuzminykh marked this pull request as draft January 18, 2024 06:54
@NicolaAK NicolaAK marked this pull request as ready for review January 18, 2024 10:39
@NicolaAK NicolaAK requested a review from fogarea January 19, 2024 12:58
saveInClientStorage();
});

window.addEventListener('beforeunload', saveInClientStorage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Зачем эта строчка?
  2. Обращение к window, document всегда должно быть в хуке, а не просто в компоненте
  3. Нельзя просто так обращаться к window, document, потому что их нет в ssr режиме

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В момент перезагрузки страницы, данные не записывались в localstorage.
Переделал, добавил хук useBeforeUnload с его помощью сохраняет в localstorage.
Если такой вариант не подойдет, предлагаю созвониться

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хорошо, такое решение подойдет. Но нужно проверить его в режиме SSR. Попробуй запустить сайт стероидов локально командой yarn ssr, если все корректно отработает, то можешь мержить этот pr

@Daria-Kuzminykh Daria-Kuzminykh marked this pull request as draft January 22, 2024 03:28
@NicolaAK NicolaAK marked this pull request as ready for review January 31, 2024 04:44
@fogarea fogarea merged commit 91e688b into master Feb 2, 2024
2 checks passed
@fogarea fogarea deleted the steroids/dev#578 branch February 2, 2024 05:52
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.

3 participants