Skip to content

Instantly share code, notes, and snippets.

View emanueleDiVizio's full-sized avatar

Emanuele emanueleDiVizio

View GitHub Profile
import store from './reduxStore';
import React from 'react';
import { Provider } from 'react-redux';
import { ReduxNetworkProvider } from 'react-native-offline';
let App = () => (
<Navigator>
<MainScreen />
<OtherScreen />
</Navigator>
import { createStore, combineReducers } from 'redux'
import { reducer as network } from 'react-native-offline';
const rootReducer = combineReducers({
// ... your other reducers here ...
network,
});
const store = createStore(rootReducer);
export default store;
import { all } from 'redux-saga/effects';
import saga1 from './saga1';
import saga2 from './saga2';
import { networkSaga } from 'react-native-offline';
export default function* rootSaga(): Generator<*, *, *> {
yield all([
fork(saga1),
fork(saga2),
fork(networkSaga, { pingInterval: 20000 }),
// rootSaga.js
import { all } from 'redux-saga/effects';
import saga1 from './saga1';
import saga2 from './saga2';
import { networkSaga } from 'react-native-offline';
export default function* rootSaga(): Generator<*, *, *> {
yield all([
fork(saga1),
fork(saga2),
// Root.js
import store from './reduxStore';
import React from 'react';
import { Provider } from 'react-redux';
import { ReduxNetworkProvider } from 'react-native-offline';
let App = () => (
<Navigator>
<MainScreen />
<OtherScreen />
// configureStore.js
import { createStore, combineReducers } from 'redux'
import { reducer as network } from 'react-native-offline';
const rootReducer = combineReducers({
// ... your other reducers here ...
network,
});
const store = createStore(rootReducer);
const ShiftBadge = () => {
const isOnShift = useIsOnShift()
return isOnShift ? (
<View style={styles.container}>
<Text style={styles.text}>
Currently on shift and receiving reminders
</Text>
</View>
) : (
const ShiftButton = () => {
const dispatch = useDispatch()
const isOnShift = useIsOnShift()
const onUserPressButton = () => {
isOnShift
? dispatch(shiftSlice.actions.endShift())
: dispatch(shiftSlice.actions.startShift())
}
const lastShiftSelector = state => state.shifts.slice(-1)[0]
const useIsOnShift = () => {
const lastShift = useSelector(lastShiftSelector)
const currentTime = useCurrentTime()
const [isOnShift, setIsOnShift] = useState(false)
useEffect(() => {
if (lastShift) {
const lastShiftSelector = state => state.shifts.slice(-1)[0]
const ShiftButton = () => {
const dispatch = useDispatch()
const currentTime = useCurrentTime()
const lastShift = useSelector(lastShiftSelector)
const [isOnShift, setIsOnShift] = useState(false)
useEffect(() => {