web-infra-dev / rspress

🦀💨 A fast Rspack-based static site generator.
https://rspress.dev
MIT License
1.36k stars 120 forks source link

fix: tabData undefined when syncIndex #1028

Closed Timeless0911 closed 5 months ago

Timeless0911 commented 5 months ago

Summary

Related Issue

Checklist

netlify[bot] commented 5 months ago

Deploy Preview for aquamarine-blini-95325f ready!

Name Link
Latest commit 57b8e75d74b1fce5c55f890aacce4b097d2a6e99
Latest deploy log https://app.netlify.com/sites/aquamarine-blini-95325f/deploys/662b84e1de480e000834eaef
Deploy Preview https://deploy-preview-1028--aquamarine-blini-95325f.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

Lighthouse
1 paths audited
Performance: 80 (🟢 up 2 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Timeless0911 commented 5 months ago

@shulaoda hi, I encoutered an issue like image

Please help me to see if there is any problem with this fix pr.

shulaoda commented 5 months ago

hi, I encoutered an issue like

The initial value of tabData is {}, should there be no problem under normal circumstances?

Perhaps here should be {tabData:{},setTabData:()=>{}}

image
Timeless0911 commented 5 months ago

https://github.com/web-infra-dev/rspress/blob/c8eee029ff02247abf12ef5ef3f914f9ff1e3c12/packages/theme-default/src/components/Search/SearchPanel.tsx#L315

I encouter this issue in this component

shulaoda commented 5 months ago

I encouter this issue in this component

Have you started running? Or is it just a TS detection error

Timeless0911 commented 5 months ago

runtime error, tabdata print out to be undefined. May be we should add some protection code.

shulaoda commented 5 months ago

Perhaps here should be {tabData:{},setTabData:()=>{}}image

I think it's caused by the initial value of createContext. Can you try again after changing it?

Timeless0911 commented 5 months ago

I was eating dinner earlier hh.

There is indeed a problem with the initialization here, after changing it, it behaves right. Awesome!

Timeless0911 commented 5 months ago

!canary