Skip to content

Commit

Permalink
Inital Linter Setup with Actions (#88)
Browse files Browse the repository at this point in the history
* Inital Linter Setup

* Fixed Linting Errors From Eslint
  • Loading branch information
EricWang228 authored Oct 11, 2024
1 parent 425d0de commit d4a51c6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Linter
on:
push:
branches:
- main

jobs:
eslint:
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install dependencies
run: |
cd client
npm install
- name: Run eslint
run: |
cd client
npm run lint -- --fix
17 changes: 14 additions & 3 deletions client/contexts/DarkModeContext.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { createContext, useState, useContext } from 'react';
import React, { createContext, useState, useContext, useMemo, useCallback } from 'react';
import PropTypes from 'prop-types';

const DarkModeContext = createContext();

Expand All @@ -9,11 +10,21 @@ export function useDarkMode() {
export function DarkModeProvider({ children }) {
const [isDarkMode, setIsDarkMode] = useState(false);

const toggleSwitch = () => setIsDarkMode(!isDarkMode);
// Wrap toggleSwitch in useCallback to prevent re-creation on every render
const toggleSwitch = useCallback(() => {
setIsDarkMode((prev) => !prev);
}, []);

// Memoize the context value
const value = useMemo(() => ({ isDarkMode, toggleSwitch }), [isDarkMode, toggleSwitch]);

return (
<DarkModeContext.Provider value={{ isDarkMode, toggleSwitch }}>
<DarkModeContext.Provider value={value}>
{children}
</DarkModeContext.Provider>
);
}

DarkModeProvider.propTypes = {
children: PropTypes.node.isRequired,
};
1 change: 1 addition & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"expo-notifications": "^0.28.16",
"expo-sms": "^12.0.1",
"expo-status-bar": "^1.12.1",
"prop-types": "^15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "^0.74.5",
Expand Down
4 changes: 4 additions & 0 deletions client/services/sms.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Function not used, please finish implementation

/*
import * as SMS from 'expo-sms';
const sendAlarmNotification = async (phoneNumber) => {
Expand All @@ -6,3 +9,4 @@ const sendAlarmNotification = async (phoneNumber) => {
await SMS.sendSMSAsync(phoneNumber, 'Alarm missed! Wake up!');
}
};
*/

0 comments on commit d4a51c6

Please sign in to comment.