|
|
@ -2,7 +2,6 @@ import React from "react"; |
|
|
|
import useShape from "../../ng-mock/js-land/frontendAdapters/react/useShape"; |
|
|
|
import useShape from "../../ng-mock/js-land/frontendAdapters/react/useShape"; |
|
|
|
import flattenObject from "../utils/flattenObject"; |
|
|
|
import flattenObject from "../utils/flattenObject"; |
|
|
|
import { TestObjectShapeType } from "src/shapes/ldo/testShape.shapeTypes"; |
|
|
|
import { TestObjectShapeType } from "src/shapes/ldo/testShape.shapeTypes"; |
|
|
|
import type { TestObject } from "src/shapes/ldo/testShape.typings"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function HelloWorldReact() { |
|
|
|
export function HelloWorldReact() { |
|
|
|
const state = useShape(TestObjectShapeType); |
|
|
|
const state = useShape(TestObjectShapeType); |
|
|
@ -10,7 +9,7 @@ export function HelloWorldReact() { |
|
|
|
// @ts-expect-error
|
|
|
|
// @ts-expect-error
|
|
|
|
window.reactState = state; |
|
|
|
window.reactState = state; |
|
|
|
|
|
|
|
|
|
|
|
if (!("id" in state)) return <>Loading state</>; |
|
|
|
if (!state) return <>Loading state</>; |
|
|
|
|
|
|
|
|
|
|
|
// Create a table from the state object: One column for keys, one for values, one with an input to change the value.
|
|
|
|
// Create a table from the state object: One column for keys, one for values, one with an input to change the value.
|
|
|
|
|
|
|
|
|
|
|
@ -18,7 +17,14 @@ export function HelloWorldReact() { |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<p>Rendered in React</p> |
|
|
|
<p>Rendered in React</p> |
|
|
|
|
|
|
|
|
|
|
|
<button onClick={() => state}>click me to change multiple props</button> |
|
|
|
<button |
|
|
|
|
|
|
|
onClick={() => { |
|
|
|
|
|
|
|
state.boolValue = !state.boolValue; |
|
|
|
|
|
|
|
state.numValue += 2; |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
click me to change multiple props |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
|
|
|
|
<table border={1} cellPadding={5}> |
|
|
|
<table border={1} cellPadding={5}> |
|
|
|
<thead> |
|
|
|
<thead> |
|
|
|