-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-renderer): setup custom React renderer (#295)
- Loading branch information
1 parent
7d32907
commit 953c221
Showing
28 changed files
with
221 additions
and
64 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
packages/react-sandbox/README.md → packages/react-renderer/README.md
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
File renamed without changes.
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
File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions
4
packages/react-sandbox/public/manifest.json → packages/react-renderer/public/manifest.json
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
File renamed without changes.
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
File renamed without changes.
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,32 @@ | ||
import { useCallback, useState } from 'react'; | ||
import Logo from './logo.svg'; | ||
import './App.css'; | ||
|
||
function App() { | ||
const [count, setCount] = useState<number>(0); | ||
const inc = useCallback(() => { | ||
setCount(count => count + 1); | ||
}, []); | ||
const dec = useCallback(() => { | ||
setCount(count => count - 1); | ||
}, []); | ||
|
||
return ( | ||
<div className="app"> | ||
<header className="app-header"> | ||
<Logo className="app-logo" title="logo" /> | ||
<div className="flex flex-row justify-center items-center"> | ||
<button className="p-4 text-white text-6xl" onClick={dec}> | ||
- | ||
</button> | ||
<div className="p-4 text-white text-6xl">{count}</div> | ||
<button className="p-4 text-white text-6xl" onClick={inc}> | ||
+ | ||
</button> | ||
</div> | ||
</header> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
3 changes: 3 additions & 0 deletions
3
packages/react-sandbox/src/index.css → packages/react-renderer/src/index.css
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,4 +1,7 @@ | ||
@import-normalize; | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
body { | ||
margin: 0; | ||
|
4 changes: 2 additions & 2 deletions
4
packages/react-sandbox/src/index.tsx → packages/react-renderer/src/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
File renamed without changes
File renamed without changes.
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,18 @@ | ||
import type { ReactElement } from 'react'; | ||
import type { Container } from './reconciler'; | ||
import Reconciler from './reconciler'; | ||
|
||
const Renderer = { | ||
render: ( | ||
element: ReactElement, | ||
container: Container | null, | ||
callback?: Function | ||
) => { | ||
if (container) { | ||
const root = Reconciler.createContainer(container, 0, false, null); | ||
Reconciler.updateContainer(element, root, null); | ||
} | ||
}, | ||
}; | ||
|
||
export default Renderer; |
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,124 @@ | ||
import type { HostConfig } from 'react-reconciler'; | ||
import ReactReconciler from 'react-reconciler'; | ||
|
||
type Type = string; | ||
type Props = { [key: string]: any }; | ||
export type Container = Document | DocumentFragment | Element; | ||
type Instance = Element; | ||
type TextInstance = Text; | ||
|
||
type SuspenseInstance = any; | ||
type HydratableInstance = any; | ||
type PublicInstance = any; | ||
type HostContext = any; | ||
type UpdatePayload = any; | ||
type _ChildSet = any; | ||
type TimeoutHandle = any; | ||
type NoTimeout = number; | ||
|
||
const hostConfig: HostConfig< | ||
Type, | ||
Props, | ||
Container, | ||
Instance, | ||
TextInstance, | ||
SuspenseInstance, | ||
HydratableInstance, | ||
PublicInstance, | ||
HostContext, | ||
UpdatePayload, | ||
_ChildSet, | ||
TimeoutHandle, | ||
NoTimeout | ||
> = { | ||
supportsMutation: false, | ||
supportsPersistence: false, | ||
createInstance: function ( | ||
type: string, | ||
props: Props, | ||
rootContainer: Container, | ||
hostContext: any, | ||
internalHandle: any | ||
): Element { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
createTextInstance: function ( | ||
text: string, | ||
rootContainer: Container, | ||
hostContext: any, | ||
internalHandle: any | ||
): Text { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
appendInitialChild: function ( | ||
parentInstance: Element, | ||
child: Element | Text | ||
): void { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
finalizeInitialChildren: function ( | ||
instance: Element, | ||
type: string, | ||
props: Props, | ||
rootContainer: Container, | ||
hostContext: any | ||
): boolean { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
prepareUpdate: function ( | ||
instance: Element, | ||
type: string, | ||
oldProps: Props, | ||
newProps: Props, | ||
rootContainer: Container, | ||
hostContext: any | ||
) { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
shouldSetTextContent: function (type: string, props: Props): boolean { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
getRootHostContext: function (rootContainer: Container) { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
getChildHostContext: function ( | ||
parentHostContext: any, | ||
type: string, | ||
rootContainer: Container | ||
) { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
getPublicInstance: function (instance: Element | Text) { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
prepareForCommit: function ( | ||
containerInfo: Container | ||
): Record<string, any> | null { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
resetAfterCommit: function (containerInfo: Container): void { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
preparePortalMount: function (containerInfo: Container): void { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
now: function (): number { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
scheduleTimeout: function ( | ||
fn: (...args: unknown[]) => unknown, | ||
delay?: number | ||
) { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
cancelTimeout: function (id: any): void { | ||
throw new Error('Function not implemented.'); | ||
}, | ||
noTimeout: 0, | ||
isPrimaryRenderer: false, | ||
supportsHydration: false, | ||
}; | ||
|
||
const reconciler = ReactReconciler(hostConfig); | ||
|
||
export default reconciler; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.