(Answering the question in the title: You can place metadata with custom data into the document and query for that metadata, that is often an alternative to using state. It depends on use case if it makes sense though.)
theme_style is a state (in the previous code snippet), and you update its value using theme_style.update(theme). Maybe this is related to the error you see? If not, maybe you have a stand alone example that shows the problem?