Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Update flow examples to RescriptReact.
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoc committed May 27, 2022
1 parent ca3f943 commit 9ed21d9
Show file tree
Hide file tree
Showing 23 changed files with 77 additions and 357 deletions.
7 changes: 2 additions & 5 deletions examples/flow-react-example/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
"language": "flow",
"module": "es6",
"importPath": "relative",
"reasonReactPath": "reason-react/src/ReasonReact.js",
"shims": {
"Js": "Js",
"Obj": "Obj",
"React": "ReactShim",
"ReactEvent": "ReactEvent",
"RescriptPervasives": "RescriptPervasives",
"ReasonReact": "ReactShim"
"RescriptPervasives": "RescriptPervasives"
},
"debug": {
"all": false
Expand All @@ -21,7 +18,7 @@
"name": "flow-react-example",
"bsc-flags": ["-bs-super-errors"],
"reason": { "react-jsx": 3 },
"bs-dependencies": ["reason-react"],
"bs-dependencies": ["@rescript/react"],
"sources": [
{
"dir": "src",
Expand Down
18 changes: 18 additions & 0 deletions examples/flow-react-example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/flow-react-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@babel/preset-env": "^7.11.5",
"@babel/preset-flow": "^7.10.4",
"@babel/preset-react": "^7.10.4",
"@rescript/react": "^0.10.3",
"babel-loader": "^8.1.0",
"concurrently": "^3.5.0",
"rescript": "9.1.1",
Expand Down
28 changes: 1 addition & 27 deletions examples/flow-react-example/src/AutoAnnotate.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions examples/flow-react-example/src/AutoAnnotate.gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,10 @@
* @nolint
*/
/* eslint-disable */
// $FlowExpectedError[unclear-type]: Reason checked type sufficiently
type $any = any;

// $FlowExpectedError[untyped-import]: Reason checked type sufficiently
import * as Curry from 'rescript/lib/es6/curry.js';

// $FlowExpectedError[untyped-import]: Reason checked type sufficiently
import * as AutoAnnotateBS from './AutoAnnotate.bs';

// flowlint-next-line nonstrict-import:off
import type {actionless as ReasonReact_actionless} from '../src/shims/ReactShim.shim';

// flowlint-next-line nonstrict-import:off
import type {componentSpec as ReasonReact_componentSpec} from '../src/shims/ReactShim.shim';

// flowlint-next-line nonstrict-import:off
import type {noRetainedProps as ReasonReact_noRetainedProps} from '../src/shims/ReactShim.shim';

// flowlint-next-line nonstrict-import:off
import type {stateless as ReasonReact_stateless} from '../src/shims/ReactShim.shim';

export type variant = {| tag: "R", value: number |};

export type record = {| +variant: variant |};
Expand All @@ -41,11 +24,4 @@ export type annotatedVariant =

export type r5 = {| +r5: number |};

export type r6 = {| +r6: number |};

export const useR5: (r5) => r5 = AutoAnnotateBS.useR5;

export const make: <T1>({| +r6: r6 |}, T1) => ReasonReact_componentSpec<ReasonReact_stateless,ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_noRetainedProps,ReasonReact_actionless> = function <T1>(Arg1: $any, Arg2: $any) {
const result = Curry._2(AutoAnnotateBS.make, Arg1.r6, Arg2);
return result
};
9 changes: 0 additions & 9 deletions examples/flow-react-example/src/AutoAnnotate.res
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,3 @@ type r5 = {r5: int}
let useR5 = (x: r5) => x

type r6 = {r6: int}

let component = ReasonReact.statelessComponent(__MODULE__)

@genType
let make = (~r6 as _: r6, _children) => {
...component,
render: _ => ReasonReact.null,
}

4 changes: 2 additions & 2 deletions examples/flow-react-example/src/Component2.res
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type action =
let make = (~greeting) => {
let message = "You've clicked this " ++ ("xx" ++ " times(s)")
<div>
<button> {ReasonReact.string(message)} </button>
<button> {ReasonReact.string("Toggle greeting")} </button>
<button> {React.string(message)} </button>
<button> {React.string("Toggle greeting")} </button>
{React.string(greeting)}
</div>
}
Expand Down
2 changes: 2 additions & 0 deletions examples/flow-react-example/src/Hooks.gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type testReactRef = { current: (null | number), ... };

export type testDomRef = React$Ref<mixed>;

export type testDOMReft = React$Ref<mixed>;

export type notAFunctionComponent = ({ current: (null | number), ... }) => React$Node;

export type Props = {| +vehicle: vehicle |};
Expand Down
10 changes: 6 additions & 4 deletions examples/flow-react-example/src/Hooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module Inner = {

module NoProps = {
@genType @react.component
let make = () => <div> ReasonReact.null </div>
let make = () => <div> React.null </div>
}

type cb = (~_to: vehicle) => unit
Expand All @@ -71,7 +71,7 @@ let makeWithRef = (~vehicle) => {
let _ = 42
ref =>
switch ref->Js.Nullable.toOption {
| Some(ref) => <button ref={ReactDOMRe.Ref.domRef(ref)}> {React.string(vehicle.name)} </button>
| Some(ref) => <button ref={ReactDOM.Ref.domRef(ref)}> {React.string(vehicle.name)} </button>
| None => React.null
}
}
Expand All @@ -94,7 +94,10 @@ type testReactContext = React.Context.t<int>
type testReactRef = React.ref<int>

@genType
type testDomRef = ReactDOMRe.domRef
type testDomRef = ReactDOM.domRef

@genType
type testDOMReft = ReactDOM.Ref.t

@genType @react.component
let polymorphicComponent = (~p as (x, _)) => React.string(x.name)
Expand All @@ -116,4 +119,3 @@ let aComponentWithChildren = (~vehicle, ~children) =>

@genType
type notAFunctionComponent = React.ref<int> => React.element

4 changes: 2 additions & 2 deletions examples/flow-react-example/src/Index.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions examples/flow-react-example/src/Index.res
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ReactDOMRe.renderToElementWithId(<Component2 greeting="Hello!" />, "index2")

ReactDOM.render(<Component2 greeting="Hello!" />, "index2"->Obj.magic)
35 changes: 9 additions & 26 deletions examples/flow-react-example/src/components/Navigator.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 2 additions & 18 deletions examples/flow-react-example/src/components/Navigator.gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,9 @@
// $FlowExpectedError[unclear-type]: Reason checked type sufficiently
type $any = any;

// $FlowExpectedError[untyped-import]: Reason checked type sufficiently
import * as Curry from 'rescript/lib/es6/curry.js';

// $FlowExpectedError[untyped-import]: Reason checked type sufficiently
import * as NavigatorBS from './Navigator.bs';

// flowlint-next-line nonstrict-import:off
import type {actionless as ReasonReact_actionless} from '../../src/shims/ReactShim.shim';

// flowlint-next-line nonstrict-import:off
import type {componentSpec as ReasonReact_componentSpec} from '../../src/shims/ReactShim.shim';

// flowlint-next-line nonstrict-import:off
import type {noRetainedProps as ReasonReact_noRetainedProps} from '../../src/shims/ReactShim.shim';

// flowlint-next-line nonstrict-import:off
import type {stateless as ReasonReact_stateless} from '../../src/shims/ReactShim.shim';
export type Props<history,match> = {| +history: history, +match: match |};

export const make: <T1,T2,T3>({| +history: T1, +match: T2 |}, T3) => ReasonReact_componentSpec<ReasonReact_stateless,ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_noRetainedProps,ReasonReact_actionless> = function <T1,T2,T3>(Arg1: $any, Arg2: $any) {
const result = Curry._3(NavigatorBS.make, Arg1.history, Arg1.match, Arg2);
return result
};
export const make: React$ComponentType<{| +history: $any, +match: $any |}> = NavigatorBS.make;
16 changes: 5 additions & 11 deletions examples/flow-react-example/src/components/Navigator.res
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
let component = ReasonReact.statelessComponent("Navigator")

type action =
| Navigate(string)
| Logout

@genType
let make = (~history, ~match as match_, _children) => {
...component,
render: _self => {
Js.log2("history", history)
Js.log2("match", match_)
<div />
},
@genType @react.component
let make = (~history, ~match as match_) => {
Js.log2("history", history)
Js.log2("match", match_)
<div />
}

32 changes: 8 additions & 24 deletions examples/flow-react-example/src/components/RenameProps.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9ed21d9

Please sign in to comment.