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(useLocal/SessionStorageState): use T as previous state type #1728

Closed
wants to merge 2 commits into from

Conversation

CHOYSEN
Copy link

@CHOYSEN CHOYSEN commented Jul 1, 2022

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

#1630

💡 Background and solution

Before:

const [name, setName] = useLocalStorageState<string>('name', { defaultValue: '' });
setName((n) => n.slice(1));
// (parameter) n: string | undefined
// 检测到无法访问的代码。ts(7027)
// 对象可能为“未定义”。ts(2532)

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@CLAassistant
Copy link

CLAassistant commented Jul 1, 2022

CLA assistant check
All committers have signed the CLA.

@liuyib liuyib changed the title fix(types): use T as previous state type fix(useLocal/SessionStorageState): use T as previous state type Mar 11, 2023
@liuyib liuyib self-requested a review March 11, 2023 10:02
@liuyib
Copy link
Collaborator

liuyib commented Jul 5, 2023

same: #2148, and #2148 is better

@liuyib liuyib closed this Jul 5, 2023
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