-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Fixed the Function Component Example #2019
Conversation
We experienced that the documentation was faulty so after we at @enpit found a fix, we wanted to share it with you. The old trigger `appState.current.match(/inactive|background/) && nextAppState === "active"` would never work because the useState hook doesn't update the state fast enough for the function to work. The solution is to use useRef instead and optional (to display the inactive status under iOS) also use a `useState` for cosmetics.
Hi @devofthings! Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Deploy preview for react-native ready! Built with commit ed0beb5 https://deploy-preview-2019--react-native.netlify.app Changes to Thank you for your contributions. |
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.
Hi @devofthings, thank you for improving example and sharing your code. Usually we don't want to see block comments in the Snack examples. If you think it's important information, please rewrite the content as a sentence above or below the example.
removed the block comment from code and added it as a descriptive text above. Some spaces were removed because the code was too indented.
@Simek I removed the block statement and added a descriptive text. |
* Fix wrong endBlock in text.md (facebook#1991) * fix: update installation instructions (facebook#1989) * Fixed DrawerLayoutAndroid padding syntax which was causing the Expo Snack to crash (facebook#1995) * Docs: Update react-native-unimodules link (facebook#1994) The react-native-unimodules link is updated. The current repo has been deprecated in favor of expo/expo monorepo * Bug Fix facebook#1993 (facebook#1996) * remove letter "s" inputaccesoryview.md (facebook#1997) * use platform labels on the Accessibility page (facebook#1948) * order accessibilityRoles alphabetically * Getting Rid of In-Content Links (facebook#1970) * Got rid of intext links and updated referenes to navigator * Removed package lock * add NavigationIOS removal notice, update links Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com> * Add two words to platform-specific-code.md (facebook#1999) * update second example in Flatlist docs (facebook#1998) * update flatlist example, select one button and change color * complete changes in examples * retain Item as separate component, use native StatusBar height, prettier run Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com> * Update accessibilityinfo.md (facebook#1977) * Update accessibilityinfo.md Since AccessibilityInfo.fetch is deprecated, I changed it with AccessibilityInfo.isReduceMotionEnabled and AccessibilityInfo.isScreenReaderEnabled * fix syntax error, remove web platform, tweak readability Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com> * fix reported invalid links (facebook#1981) * changes from the Prettier run (facebook#2000) * fix links in images.md (facebook#2002) * fix onPageNav height with announcement (facebook#2006) * Fix bug in example of functional component (facebook#2004) * Remove legacyImplementation (facebook#2012) facebook/react-native@636d01b * Replace YellowBox docs with LogBox docs. (facebook#2020) * Replace YellowBox docs with LogBox docs. * Fix language lint errors * Update debugging.md Some typos and rewordings * Update debugging.md Co-authored-by: Eli White <github@eli-white.com> * Update flatlist.md (facebook#2022) Example in renderItem Have a syntax error in ItemSeparatorComponent * Fixed code snippet. (facebook#2015) new ReactImageManager(..here..), ReactImageManager 's constructer needs reactContext, we passed it. * Remove duplicate documentation property for statusBarTranslucent on Modal (facebook#2023) * Remove duplicate documentation property for statusBarTranslucent on Modal * Sort properties alphabetically * Add an ability to slide up announcement bar on scroll (facebook#2018) * slide up announcement banner on scroll * fix for desktop resizing on macOS * apply fix only on mobile * remove unused variables declarations and parameters in different files. (facebook#2010) * delete unused variables declarations and parameters * remove accent in parameters * add variable params * Fixed the Function Component Example (facebook#2019) * Fixed the Function Component Example We experienced that the documentation was faulty so after we at @enpit found a fix, we wanted to share it with you. The old trigger `appState.current.match(/inactive|background/) && nextAppState === "active"` would never work because the useState hook doesn't update the state fast enough for the function to work. The solution is to use useRef instead and optional (to display the inactive status under iOS) also use a `useState` for cosmetics. * removed block comment, removed spaces * rephrase and move new comment, add one more sentence, prettier run * language lint fix Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com> * Blog post for the 0.63 release (facebook#2024) * commit the article * Update 2020-07-06-version-0.63.md * Update 2020-07-06-version-0.63.md * Update website/blog/2020-07-06-version-0.63.md Co-authored-by: Ricky <rickhanlonii@gmail.com> * Update website/blog/2020-07-06-version-0.63.md Co-authored-by: Ricky <rickhanlonii@gmail.com> * Update website/blog/2020-07-06-version-0.63.md Co-authored-by: Ricky <rickhanlonii@gmail.com> * Update 2020-07-06-version-0.63.md * chore: refactor to a css * Updating the Pressable introduction Co-authored-by: Ricky <rickhanlonii@gmail.com> Co-authored-by: Eli White <github@eli-white.com> * feat: ship 0.63 docs (facebook#2030) * Fix Alert API docs (facebook#2027) * Fix Alert API docs * Update docs/alert.md Co-authored-by: Ricky <rickhanlonii@gmail.com> * Update docs/alert.md Co-authored-by: Ricky <rickhanlonii@gmail.com> * Update docs/alert.md Co-authored-by: Ricky <rickhanlonii@gmail.com> Co-authored-by: Ricky <rickhanlonii@gmail.com> * adding docs for android_hyphenationStrategy (facebook#2007) * updated default folder location for Android Sdk in Windows (facebook#2008) * updated default folder location for Android Sdk in Windows Matching the configuration screenshot of the default folder location. I had some trouble during environment configuration when I figured out that the location from the screenshot provided was the correct one (for the Sdk location). * Update docs/getting-started.md Co-authored-by: Kid <44045911+kidonng@users.noreply.github.com> * Link to the actual Upgrade Helper, not the GitHub repo for it (facebook#2034) Co-authored-by: Michal <developer239@users.noreply.github.com> Co-authored-by: Rogi Solorzano <36051536+rogisolorzano@users.noreply.github.com> Co-authored-by: Tim Pap <blackpr.tim@gmail.com> Co-authored-by: Nayan Shinde <shinde.nayan16@gmail.com> Co-authored-by: luism3861 <36824170+luism3861@users.noreply.github.com> Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com> Co-authored-by: JP Bulman <jpbulman@wpi.edu> Co-authored-by: Doga Fincan <doga@icloud.com> Co-authored-by: truecuozzo98 <52197438+truecuozzo98@users.noreply.github.com> Co-authored-by: ttlong3103 <tranthanhlong3103@gmail.com> Co-authored-by: Ricky <rickhanlonii@gmail.com> Co-authored-by: Eli White <github@eli-white.com> Co-authored-by: SABRYX <32037441+SABRYX@users.noreply.github.com> Co-authored-by: Surya Chandra Pavan Adurthi <p2pdops@gmail.com> Co-authored-by: Levi Buzolic <levibuzolic@gmail.com> Co-authored-by: Chris Winter <chris-winter@live.de> Co-authored-by: Mike Grabowski <grabbou@gmail.com> Co-authored-by: Ankit Tiwari <ankitt255@gmail.com> Co-authored-by: fabriziobertoglio1987 <fabrizio.bertoglio@gmail.com> Co-authored-by: Celso Wellington <celso.w.dias.a@gmail.com> Co-authored-by: Kid <44045911+kidonng@users.noreply.github.com> Co-authored-by: Steven Conaway <steven.conaway@icloud.com>
We experienced that the documentation was faulty so after we at @enpit found a fix, we wanted to share it with you.
The old trigger
appState.current.match(/inactive|background/) && nextAppState === "active"
would never work because the useState hook doesn't update the state fast enough for the function to work. The solution is to use useRef instead and optional (to display the inactive status under iOS) also use auseState
for cosmetics.