diff --git a/private/helloworld/App.tsx b/private/helloworld/App.tsx index 09f7928a852..f56dc1b9f3d 100644 --- a/private/helloworld/App.tsx +++ b/private/helloworld/App.tsx @@ -1,42 +1,73 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - */ - -import * as React from 'react'; +import React from 'react'; import { SafeAreaView, - ScrollView, - StatusBar, StyleSheet, Text, - View, - useColorScheme, + TextInput, + Button, } from 'react-native'; -function App(): React.ReactNode { - const isDarkMode = useColorScheme() === 'dark'; +import NativeLocalStorage from './specs/NativeLocalStorage'; + +const EMPTY = ''; + +function App(): React.JSX.Element { + const [value, setValue] = React.useState(null); + + const [editingValue, setEditingValue] = React.useState< + string | null + >(null); + + React.useEffect(() => { + const storedValue = NativeLocalStorage?.getItem('myKey'); + setValue(storedValue ?? ''); + }, []); + + function saveValue() { + NativeLocalStorage?.setItem(editingValue ?? EMPTY, 'myKey'); + setValue(editingValue); + } + + function clearAll() { + NativeLocalStorage?.clear(); + setValue(''); + } + + function deleteValue() { + NativeLocalStorage?.removeItem('myKey'); + setValue(''); + } return ( - - - - - Hello, World! - - + + + Current stored value is: {value ?? 'No Value'} + + +