cferdinandi / reef

A lightweight library for creating reactive, state-based components and UI.
https://reefjs.com
MIT License
1.16k stars 77 forks source link

Is there a way to force a component to "rerender" without adding content? #168

Closed mouse0270 closed 2 years ago

mouse0270 commented 2 years ago

I use a component and inside this component I format the responding HTML based on a user setting. So that they can customize the look and feel of their app.

The problem is, since this is just changing the function that is being called inside of the component and not the store, the component doesn't update with the new layout until the user does something to change the store or reload their page.

Is there a way to force either the component to rerender or basically trigger the store to update so that component rerenders without actually updating the store? I'd like to make this as smooth as a transition as possible for the user without forcing them to reload.

mouse0270 commented 2 years ago

Duh, I could save the theme into the store, and when I update the theme, that would update the store causing the component to rerender... Duh...

cferdinandi commented 2 years ago

Components also have a render() method that I just noticed isn’t documented. I’ll update the docs soon.

cferdinandi commented 2 years ago

Updated the docs: https://reefjs.com/api/#component