Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooks #30

Closed
miralemd opened this issue May 13, 2019 · 0 comments
Closed

Hooks #30

miralemd opened this issue May 13, 2019 · 0 comments
Milestone

Comments

@miralemd
Copy link
Contributor

The hooks concept introduced by React could be very fitting to use since a component in supernova is very similar in terms of lifecycle. Custom hooks could easily be shared for reusability and increased productivity.

Example hooks:

  • useState to handle state (same as React)
  • useLayout to consume a layout
  • useModel to access the current object's enigma model
  • useApp to access the app model
  • useTheme to consume a theme
  • useResize to handle a resize
import { useLayout, useResize } from '@nebula.js/supernova'

export default function() {
  {
    qae: { /* */ },
    component() {
      const [state, setState] = useState({});
      const [layout] = useLayout();
      useResize(() => { /* do stuff on resize */ });

      // render stuff
    }
  }
}
@miralemd miralemd mentioned this issue Jan 10, 2020
@miralemd miralemd added this to the 1.0.0 milestone Jan 13, 2020
@miralemd miralemd closed this as completed Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant