Allow useArchive and useArchiveProperty clients to resolve references.
Compare changes
Beginning with 2nd June, only the "Single Sign On" option for login to the GitLab web interface will be possible. If you don't have an MPCDF wide second factor so far, please get one at our SelfService (https://selfservice.mpcdf.mpg.de). The GitLab internal second factor will not work.
This MR provides the functionality that is need to useArchive
and resolve references. This should now be used like this:
const {value, resolveRef} = useArchiveProperty('results/properties/electronic')
const dos = resolveRef(value.dos_electronic.total[0])
const docValues = dos.value
If the useArchiveProperty
call is far away from the resolveRef
call, the resovleRef
can also be grabbed from useArchive
within any arbitrary child component:
In the parent:
const {value, resolveRef} = useArchiveProperty('results/material/properties/electronic')
return <SomeSubComponent electronicProperties={value}/>
In some SubSubSubComponent:
const archive = useArchive()
...
archive.resolveRef(...)
Alternatively, you can also use just useArchive
:
const archive = useArchive()
...
archive.resolveRef(archive.archive.result.properties.electronic.dos_electronic.total[0])
Be aware that the result of useArchive
is an instance of Archive
from useArchive.tsx
. Its not an object with keys. Don't do this
const {archive, resolveRef} = useArchive() // WRONG
Any call to resultRef
will cause an exception because the this
is not properly passed.
Instead do:
const archive = useArchive() // right
archive.resolveRef(archive.archive....)