mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 12:43:09 -05:00
refactor BudgetMonthCountContext to tsx (#1722)
* refactor BudgetMonthCountContext to tsx * add release notes
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
import React, { createContext, useContext, useState } from 'react';
|
||||
|
||||
let BudgetMonthCountContext = createContext();
|
||||
|
||||
export function BudgetMonthCountProvider({ children }) {
|
||||
let [displayMax, setDisplayMax] = useState(1);
|
||||
|
||||
return (
|
||||
<BudgetMonthCountContext.Provider value={{ displayMax, setDisplayMax }}>
|
||||
{children}
|
||||
</BudgetMonthCountContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useBudgetMonthCount() {
|
||||
return useContext(BudgetMonthCountContext);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import React, {
|
||||
createContext,
|
||||
type Dispatch,
|
||||
type ReactNode,
|
||||
type SetStateAction,
|
||||
useContext,
|
||||
useState,
|
||||
} from 'react';
|
||||
|
||||
type BudgetMonthCountContextValue = {
|
||||
displayMax: number;
|
||||
setDisplayMax: Dispatch<SetStateAction<number>>;
|
||||
};
|
||||
|
||||
let BudgetMonthCountContext = createContext<BudgetMonthCountContextValue>(null);
|
||||
|
||||
type BudgetMonthCountProviderProps = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export function BudgetMonthCountProvider({
|
||||
children,
|
||||
}: BudgetMonthCountProviderProps) {
|
||||
let [displayMax, setDisplayMax] = useState(1);
|
||||
|
||||
return (
|
||||
<BudgetMonthCountContext.Provider value={{ displayMax, setDisplayMax }}>
|
||||
{children}
|
||||
</BudgetMonthCountContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useBudgetMonthCount() {
|
||||
return useContext(BudgetMonthCountContext);
|
||||
}
|
||||
6
upcoming-release-notes/1722.md
Normal file
6
upcoming-release-notes/1722.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Maintenance
|
||||
authors: [Jod929]
|
||||
---
|
||||
|
||||
Refactor budget/BudgetMonthCountContext to tsx.
|
||||
Reference in New Issue
Block a user