itwinjs-core icon indicating copy to clipboard operation
itwinjs-core copied to clipboard

ViewState.createFromProps is misleading

Open a-gagnon opened this issue 2 years ago • 1 comments

I tried using ViewState.createFromProps by passing ViewStateProps that I previously obtained by calling ViewState.toProps(). I kept wondering why it always returned undefined until I looked at the implementation which always returns undefined... It might be a good idea to put a note to use convertViewStatePropsToViewState instead and eventually remove this entirely?


⚠ Do not edit this section. It is required for imodeljs.github.io ➟ GitHub issue linking

  • LINK: createFromPropsStatic---core-frontend-link-to-docs
  • TAG: imodeljs-docs-question
  • SOURCE: https://www.itwinjs.org/reference/core-frontend/views/viewstate/createfrompropsstatic/

a-gagnon avatar Oct 11 '23 13:10 a-gagnon

Yeah, that's weird. It is overridden (statically) in classes like SpatialViewState. I suspect the author wanted to mark it abstract, but TypeScript doesn't support abstract static methods.

The base implementation should probably check the BIS class of the supplied ViewStateProps and invoke the corresponding subclass (e.g., SpatialViewState.createFromProps).

pmconne avatar Oct 11 '23 14:10 pmconne