Skip to content

Instantly share code, notes, and snippets.

/* playing sound using react-native-sound.
We have a list of sounds and by default we are playing the first sound in the list.
In order to change the sound track a user can select the file name from the list.
Note:
1. Android: Save your sound clip files under the directory android/app/src/main/res/raw.
Note that files in this directory must be lowercase and underscored (e.g. my_file_name.mp3) and that subdirectories are not supported by Android.
2. iOS: Open Xcode and add your sound files to the project (Right-click the project and select Add Files to [PROJECTNAME])
*/
@rickyansari
rickyansari / CountDownTimerHook.jsx
Last active December 6, 2022 20:42
Count Down Timer hook. which can be used in react-native and react application.
import React, {useEffect, useState} from 'react';
const ON = 'on';
const OFF = 'off';
const defaultTimerValue = 3;
const defaultTimerInterval= 1000;
const defaultTimeOutCallback = ()=>{alert('Time Over)};
function useCountDownTimer({
initialValue = defaultTimerValue,
interval = defaultTimerInterval,