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....)