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

Functional components #29

Closed
Mortaro opened this issue Feb 26, 2021 · 2 comments
Closed

Functional components #29

Mortaro opened this issue Feb 26, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@Mortaro
Copy link
Member

Mortaro commented Feb 26, 2021

copy functional components from the times react knew its place

Implement pure functional components

functional components will receive the global context + inline attributes, but will have no state of its own

discussion: force components to be named functions for the sake of debug sanity

@Mortaro Mortaro added the enhancement New feature or request label Feb 26, 2021
@Mortaro Mortaro self-assigned this Mar 7, 2021
@Mortaro
Copy link
Member Author

Mortaro commented Mar 7, 2021

#34 Adds support to pure components with the 3 following syntaxes:

const AnonComponent = function(context) {
  return (
    <div data-anon={context.params.works} id={context.id} />
  )
}

function NamedComponent(context) {
  return (
    <div data-named={context.params.works} id={context.id} />
  )
}

const ArrowComponent = (context) => {
  return (
    <div data-arrow={context.params.works} id={context.id} />
  )
}

Functional components are pure and the context is readonly

@Mortaro
Copy link
Member Author

Mortaro commented Mar 7, 2021

pure functions now receive a proxy so bind is still possible while remaining pure:

export const ArrowComponent = (context) => {
  return (
    <input data-string={context.string} bind={context.string} />
  )
}

@Mortaro Mortaro closed this as completed Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant