import { CameraRoll, Button } from 'react-native';
export default function PhotoSaver() {
const savePhoto = async () => {
try {
// This method invokes a native module method to save an image to the Camera Roll
const savedPhoto = await CameraRoll.save(tag, { type, album });
console.log('Photo saved', savedPhoto);
} catch (error) {
console.error('Error saving photo', error);
}
};
return (
<Button title="Save Photo" onPress={savePhoto} />
);
}
npx react-native run-android
sudo xcodebuild -license
sudo gem install cocoapods
brew install node
brew install watchman
cd ios
pod install
class UserGreeting extends React.Component {
constructor(props) {
super(props);
this.state = { isLoggedIn: false };
}
// Lifecycle methods for side effects, data fetching, etc.
componentDidMount() {
// Code to run on component mount
}
render() {
const { isLoggedIn } = this.state;
return <div>Welcome {isLoggedIn ? 'User' : 'Guest'}</div>;
}
}
function UserGreeting() {
const [isLoggedIn, setIsLoggedIn] = React.useState(false);
// Hooks for managing state, side effects, context, etc.
React.useEffect(() => {
// Code to run on component mount or update
}, []);
return <div>Welcome {isLoggedIn ? 'User' : 'Guest'}</div>;
}