Component - Device info and haptics
This React Native component shows basic device information and provides a button to trigger a vibration (haptic feedback) on the device. It helps users feel a physical response when they tap the button.
This React Native component shows basic device information and provides a button to trigger a vibration (haptic feedback) on the device. It helps users feel a physical response when they tap the button.
View ├─ Text (Device Info) └─ Button (Trigger Vibration)
Platform module in React Native gives details about the device OS like 'ios' or 'android'.Dimensions gives screen size, Vibration controls haptic feedback, and StatusBar manages the status bar UI, not OS info.Dimensions.get('screen'), which returns an object with width and height..width property, so Dimensions.get('screen').width is correct syntax.import { Vibration } from 'react-native';
Vibration.vibrate(1000);
Choose the correct behavior.Vibration.vibrate() makes the device vibrate for that many milliseconds (1000 ms = 1 second).import { Vibration } from 'react-native';
Vibration.vibrate([500, 1000]);true is needed. Without it, the pattern runs once, so no error but possibly unintended behavior.[500, 300, 500, 300].Vibration.vibrate([500, 300, 500, 300], false) executes the sequence once without looping further.true causes indefinite looping (cancel timing imprecise); shorter pattern loops incorrectly; separate calls lack pauses.Pass the test and this pattern moves unknown