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

search keyword: 'Clean Code' break!! #1

Open
gracekrcx opened this issue Jun 26, 2022 · 0 comments
Open

search keyword: 'Clean Code' break!! #1

gracekrcx opened this issue Jun 26, 2022 · 0 comments

Comments

@gracekrcx
Copy link
Owner

gracekrcx commented Jun 26, 2022

search keyword: 'Clean Code'

因為 input 裡的 empty string 到 Url encode 後,造成 state 持續的變化,持續發出 request
所以使用 router.eventsshallow 判斷是否需要打 api

Shallow Routing
Shallow routing allows you to change the URL without running data fetching methods again, that includes getServerSideProps, getStaticProps, and getInitialProps.

細節:
The URL will get updated to /?counter=10. and the page won't get replaced, only the state of the route is changed.

 router.push('/?counter=10', undefined, { shallow: true })

Url encode

空白 =>  +
+   =>  %2B
%2B =>  %252B
gracekrcx added a commit that referenced this issue Jun 28, 2022
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

No branches or pull requests

1 participant