What am I doing wrong here?
export function Wrapper({ json }) {
console.log('Wrapper:', json)
return (
<>
<div className="label">
Code:
<input
className="editable"
type="text"
defaultValue={json.code}
/>
</div>
</>
)
}
This is the exception:
Wrapper.jsx:10
Uncaught (in promise)
TypeError: Cannot read properties of undefined (reading 'code')
at Wrapper (Wrapper.jsx:10:36)
at renderWithHooks (react-dom.development.js:15486:18)
at mountIndeterminateComponent (react-dom.development.js:20103:13)
at beginWork (react-dom.development.js:21626:16)
at beginWork$1 (react-dom.development.js:27465:14)
at performUnitOfWork (react-dom.development.js:26596:12)
at workLoopSync (react-dom.development.js:26505:5)
at renderRootSync (react-dom.development.js:26473:7)
at recoverFromConcurrentError (react-dom.development.js:25889:20)
at performSyncWorkOnRoot (react-dom.development.js:26135:20)
Here I am calling the Wrapper…
<div className="label">
Wrapper:
{console.log('Wrapper WTF:', json.wrapper)}
<Wrapper json={json.wrapper} />
</div>
Here is the json fragment of the api call…
"wrapper": {
"returnType": "System.Single",
"name": "wrapper",
"timeStep": 0,
"done": false,
"fitness": 0,
"key": null,
"value": 65,
"code": "(ConvertNegOnePosOne w)"
},
Why isn’t that json object I am passing valid? I can log it and it’s there. When I try and assign it, it’s not there…