-
Notifications
You must be signed in to change notification settings - Fork 296
Fix: persist filters on return #309
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: persist filters on return #309
Conversation
src/pages/Home/Home.tsx
Outdated
const storedFilterData = loadFilterData(); | ||
const Keys = ['search', 'priority', 'cities']; |
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.
Como essa variável keys não sofre alterações, ela pode ser definida fora do render, não sendo recriada a todo momento.
Tenho a impressão que essa storedFilterData (que não é apenas dados armazenados) pode ser criada no início do componente e seu valor passado para o useState e reutilizada depois aqui.
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.
Vou realizar esses ajuste, válido demais seu comentário
src/pages/Home/Home.tsx
Outdated
|
||
useEffect(() => { | ||
saveFilterData(filterData); | ||
}, [filterData]); |
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.
um pouco confuso storedFilterData
e filterData
referenciando a mesma coisa. eu removeria storedFilterData
, passaria o loadFilterData()
como argumento de useState
em L37 e juntaria os 2 useEffect
's
não seria mais pratico usar o context do que salvar no local ou vc criou algo para apagar depois? |
Adicione na função clearSearch para realizar a remoção |
Eu vou subir as alterações com base em todos os comentários, vlww |
Ajustado!! |
@Johnviti pode resolver o conflito, pf? |
Feito |
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.
primeiramente parabéns pelo trabalho @Johnviti
adicionei um minor e rodando localmente encontrei erros ao rodar:
npm run build
:

npm run lint
:

poderia dar uma olhada neles?
src/pages/Home/Home.tsx
Outdated
}; | ||
|
||
const loadFilterData = (): IFilterFormProps => { | ||
const storedFilterData = JSON.parse(localStorage.getItem('filterData') || '{}'); |
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.
poderia mudar filterData
pra kebab-case pra seguir o padrão local storage key names do projeto?
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.
Vou ajustar e verificar
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.
Feito
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.
LGTM! 🚀
Testado localmente e a funcionalidade atende os requisitos. O código atende e está apto a ser mergeado. |
No description provided.