-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08ec0c9
commit b3d6e95
Showing
7 changed files
with
136 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {FC} from 'react' | ||
|
||
export type JSON = string | number | boolean | null | JSON[] | { [key: string]: JSON } | ||
|
||
export interface JsonProps { | ||
value: JSON | ||
type: 'JSON' | ||
} | ||
|
||
export const JsonComp: FC<JsonProps> = ({ value }) => { | ||
// if the value is a string, we assume it's already JSON, and parse it | ||
if (typeof value === 'string') { | ||
value = JSON.parse(value) | ||
} | ||
return ( | ||
<div className="code-block"> | ||
<pre> | ||
<code>{JSON.stringify(value, null, 2)}</code> | ||
</pre> | ||
</div> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
import { createContext, FC, useContext } from 'react' | ||
import { FastProps } from '../components' | ||
|
||
export type CustomRender = (props: FastProps) => FC | null | ||
export type CustomRender = (props: FastProps) => FC | void | ||
|
||
export const CustomRenderContext = createContext<CustomRender | null>(null) | ||
|
||
export const useCustomRender = (props: FastProps): FC | null => { | ||
export const useCustomRender = (props: FastProps): FC | void => { | ||
const customRender = useContext(CustomRenderContext) | ||
|
||
if (customRender) { | ||
return customRender(props) | ||
} else { | ||
return null | ||
} | ||
} |
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