-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "check: add intentionally uncompilable code to see whe…
…ther action works or not"" This reverts commit df0850a.
- Loading branch information
1 parent
884f90e
commit dd1ee50
Showing
1 changed file
with
9 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
import {useState} from 'react'; | ||
import {useEffect, useState} from 'react'; | ||
import {useSharedValue} from 'react-native-reanimated'; | ||
|
||
// In some places we set initial value on first render, but we don't want to re-run the function | ||
// This hook will memoize the initial value and return that without setter, so it's never changed | ||
// https://github.com/Expensify/App/pull/29643#issuecomment-1765894078 | ||
export default function useInitialValue<T>(initialStateFunc: () => T) { | ||
const a = useSharedValue(0); | ||
const [initialValue] = useState(initialStateFunc); | ||
|
||
useEffect(() => { | ||
// eslint-disable-next-line react-compiler/react-compiler | ||
a.value += 1; | ||
}, []); | ||
|
||
return initialValue; | ||
} |