Allow useArchive and useArchiveProperty clients to resolve references.
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....)
Merge request reports
Activity
This should help @mnakh . The
archive.archive
will not contain the section run. But any reference you will find, e.g.archive.archive.result.properties...
can be resolved now witharchive.resolveRef
. The underlyingArchive
instance keeps the full API response and appliesresolveRef
on that. This way it works for intra and inter entry references.Let me know if this works or not. I could only add a simple test case for now. Within the reality of
results.properties...
there might be surprises. Once you rebased, I could debug this more directly on your branch.added 1 commit
- e8b28082 - Allow useArchive and useArchiveProperty clients to resolve references.
added 1 commit
- 00afacdd - Allow useArchive and useArchiveProperty clients to resolve references.
added 1 commit
- 38080c7e - Allow useArchive and useArchiveProperty clients to resolve references.
enabled an automatic merge when all merge checks for 38080c7e pass