Skip to content

Commit c1169f7

Browse files
committed
fix types
1 parent cb25a86 commit c1169f7

File tree

10 files changed

+23
-18
lines changed

10 files changed

+23
-18
lines changed

plugins/md-layout-loader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ module.exports = async function (src) {
2929
const layout = layoutMap[pageParentDir] || 'Home';
3030
const code =
3131
`import withLayout from 'components/Layout/Layout${layout}';
32-
export default withLayout(${JSON.stringify(data)})
32+
export default withLayout(${JSON.stringify(data)});
33+
34+
3335
` + content;
3436

3537
return callback(null, code);

src/components/Layout/useMediaQuery.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useCallback, useEffect, useState } from 'react';
77
const useMediaQuery = (width: number) => {
88
const [targetReached, setTargetReached] = useState(false);
99

10-
const updateTarget = useCallback((e) => {
10+
const updateTarget = useCallback((e: MediaQueryListEvent) => {
1111
if (e.matches) {
1212
setTargetReached(true);
1313
} else {

src/components/MDX/APIAnatomy.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Facebook, Inc. and its affiliates.
33
*/
44

5+
import { CodeMirrorRef } from '@codesandbox/sandpack-react/dist/types/components/CodeEditor/CodeMirror';
56
import cn from 'classnames';
67
import * as React from 'react';
78
import tailwindConfig from '../../../tailwind.config';
@@ -42,7 +43,7 @@ const colors = [
4243

4344
export function APIAnatomy({ children }: APIAnatomyProps) {
4445
const [activeStep, setActiveStep] = React.useState<number | null>(null);
45-
const ref = React.useRef<HTMLDivElement>();
46+
const ref = React.useRef<CodeMirrorRef>();
4647

4748
const { steps, code } = React.Children.toArray(children).reduce(
4849
(acc: AnatomyContent, child) => {

src/components/MDX/CodeBlock/CodeBlock.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
SandpackProvider,
99
SandpackThemeProvider
1010
} from '@codesandbox/sandpack-react';
11+
import { CodeMirrorRef } from '@codesandbox/sandpack-react/dist/types/components/CodeEditor/CodeMirror';
1112
import cn from 'classnames';
1213
import rangeParser from 'parse-numeric-range';
1314
import * as React from 'react';
@@ -36,7 +37,7 @@ const CodeBlock = React.forwardRef(
3637
noMargin?: boolean;
3738
noMarkers?: boolean;
3839
},
39-
ref?: React.Ref<HTMLDivElement>
40+
ref?: React.Ref<CodeMirrorRef>
4041
) => {
4142
const getDecoratedLineInfo = () => {
4243
if (!metastring) {

src/components/MDX/Sandpack/compile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface CompiledCode {
77
error?: any;
88
}
99

10-
type TransformFn = (x: string) => string;
10+
type TransformFn = (x: string) => string | null | undefined;
1111
const transformJsxToES5: TransformFn = (code: string) => Babel.transform(code, { presets: ['es2015', 'react'] }).code;
1212
const identity: TransformFn = x => x;
1313

src/components/MDX/Sandpack/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CustomPreset } from './CustomPreset';
1111

1212

1313
type SandpackProps = {
14-
children: React.ReactChildren;
14+
children: React.ReactNode;
1515
autorun?: boolean;
1616
setup?: SandpackSetup;
1717
};

src/components/unity/cartridge.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { useGlobalUnity } from './context';
66
import styles from './index.module.scss';
77

88
interface Props {
9-
script?: string;
10-
style?: string;
9+
script?: string | null;
10+
style?: string | null;
1111
className?: string;
1212
autoActivate?: boolean;
1313
hideActivateButton?: boolean;
@@ -24,7 +24,7 @@ export const UnityCardridge = forwardRef<UnityCardridgeRef, Props>(
2424
const latestStyle = React.useRef(style);
2525

2626
const unityContainer = React.useRef<HTMLDivElement | null>(null);
27-
const setRef = useCallback((el) => {
27+
const setRef = useCallback((el: HTMLDivElement | null) => {
2828
if (el) unityContainer.current = el;
2929
}, [unityContainer]);
3030
const { instance, insertTo, insertedToRef, setLoaded } = useGlobalUnity();

src/components/unity/instance.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function Unity({ className, sampleName = defaultUnityInstanceName, unityR
2424
return createPortal(<div style={{ width: 0, height: 0 }} id={id} />, document.body, id);
2525
}, [id])
2626

27-
const setCanvasRef = useCallback(async canvas => {
27+
const setCanvasRef = useCallback(async (canvas: HTMLCanvasElement | null) => {
2828
if (!canvas || !scriptLoaded) { return; }
2929

3030
const unityInstance: UnityInstance = await global.createUnityInstance(canvas, {

src/pages/learn/index.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ export default function App() {
3232

3333
</Sandpack>
3434

35+
### What is ReactUnity?
36+
37+
ReactUnity is a framework that lets you code UI using React and show it inside Unity.
38+
39+
ReactUnity is not a hack or a workaround. It is a legitimate way to use React. React framework is built in a way so that the React logic can be used in different platforms. In fact, all platforms which can run Javascript can have a framework like ReactUnity.
40+
41+
In Web development, it is ReactDOM. In native mobile (and desktop) applications, it is React Native. And in Unity, it is ReactUnity. There are actually more [Awesome React Renderers](https://github.com/chentsulin/awesome-react-renderer) you probably haven't heard of.
42+
3543
## How can I learn ReactUnity
3644

37-
To learn ReactUnity, you need to learn React first. You can start by the [official React documentation](https://reactjs.org/). If you already feel confident with React, then you can keep reading this documentation.
45+
To learn ReactUnity, you need to learn React first. You can start by the [official React documentation](https://reactjs.org/). If you already feel confident with React, you can keep reading this documentation.

src/pages/learn/overview.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)