-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gatsby-cli) Migrate remaining files in reporters/logger/ink to …
…Typscript (#22782) * Migrate remaining files in gatsby-cli/reporters/logger/ink to TS * Rename "IProps" to something more contextual Extend interface parameter individually instead of using utility * Clean up after merging the redux master changes Co-authored-by: Blaine Kasten <blainekasten@gmail.com>
- Loading branch information
1 parent
67730fd
commit 8ee74c1
Showing
11 changed files
with
109 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { useState, useEffect, createContext } from "react" | ||
import { getStore, onLogAction } from "../../redux" | ||
import { IGatsbyState } from "gatsby/src/redux/types" | ||
|
||
// These weird castings we are doing in this file is because the way gatsby-cli works is that it starts with it's own store | ||
// but then quickly swaps it out with the store from the installed gatsby. This would benefit from a refactor later on | ||
// to not use it's own store temporarily. | ||
// By the time this is actually running, it will become an `IGatsbyState` | ||
const StoreStateContext = createContext<IGatsbyState>( | ||
(getStore().getState() as any) as IGatsbyState | ||
) | ||
|
||
export const StoreStateProvider: React.FC = ({ | ||
children, | ||
}): React.ReactElement => { | ||
const [state, setState] = useState( | ||
(getStore().getState() as any) as IGatsbyState | ||
) | ||
|
||
useEffect( | ||
() => | ||
onLogAction(() => { | ||
setState((getStore().getState() as any) as IGatsbyState) | ||
}), | ||
[] | ||
) | ||
|
||
return ( | ||
<StoreStateContext.Provider value={state}> | ||
{children} | ||
</StoreStateContext.Provider> | ||
) | ||
} | ||
|
||
export default StoreStateContext |
9 changes: 3 additions & 6 deletions
9
...sby-cli/src/reporter/loggers/ink/index.js → ...by-cli/src/reporter/loggers/ink/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.