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

[Request] Integrate inferno-mobx with Inferno's functional components #815

Open
imetallica opened this issue Feb 8, 2017 · 5 comments
Open

Comments

@imetallica
Copy link

Is it possible to create an API for functional components?

Currently, it only supports Component classes and stateless components. So it's quite awkward if we need to generate side-effects on initialization, for example.

@imetallica
Copy link
Author

imetallica commented Feb 8, 2017

This is the error I get when I try to use mobx with functional components:

Error: Inferno Error: functional component lifecycle events are not supported on ES2015 class components

And this is my code:

const Survey = connect (['surveyStore'], function(props) {
  return (
    <div>
      <Writer onComponentDidMount={ loadEditor } />
      <a onClick={ linkEvent(props, addAnswer) }>Adicionar resposta</a>
      {props.surveyStore.answers}
    </div>
  )
})

Inferno.render(
  <Provider surveyStore={SurveyStore}>
    <Survey 
      onComponentShouldUpdate={myUpdateFunction} />
  </Provider>,
  document.getElementById("app")
)

@Havunen
Copy link
Member

Havunen commented Feb 22, 2017

Currently focus is on fixing bugs and making 1.3 stable. This is something we could implement or at least investigate for Inferno 1.4

@Havunen Havunen added this to the Future milestone Feb 22, 2017
@Havunen
Copy link
Member

Havunen commented Apr 15, 2017

I did short investigation on this and it seems that mobx is wrapping all functional components with class components to be able to re-render them...

@Havunen
Copy link
Member

Havunen commented Apr 15, 2017

Basically it means with the current state of mobx integration using functional components is anti pattern

@robbiespeed
Copy link

@Havunen I could take a look at fixing this, I'm going to be writing inferno integration for my own state management library which functions using a similar observer pattern to mobX. It wouldn't be hard to port whatever I do to mobX, my main concern is what Inferno APIs are considered stable, because doing this work would require forcing an update of a functional component which is only possible using undocumented internal functions (I think patch).

@Havunen Havunen removed this from the Future milestone May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants