Giter Club home page Giter Club logo

controllerim's People

Contributors

ismailhabib avatar maicki avatar niryo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

controllerim's Issues

Not working with any React Navigation

Controllerim seems to clash with React Navigation... when I try to navigate to a different page it's throwing the error `TypeError: Cannot read property 'findIndex' of undefined

It seems like I can navigate to another page if I remove this.controller = new SplashController(this) but obviously then I can't use the controller

And if I don't try to navigate to a different page then the page renders properly with the above line of code included

Any ideas?

Typescript?

This library looks great but we have a requirement that we must write everything in typescript. Do you have any plans to add the typings for this project?

TestUtils.getControllerOf Returns TypeError

When writing a Jest test for a App.jsx based AppController.js function using the TestUtils.getControllerOf(component.instance()) statement, I receive the following error:

TypeError: cannot read property '__reactViewControllersIdForTesting' of null.
`
describe("App Controller", () => {
beforeEach(() => {
TestUtils.init();
});

afterEach(() => {
TestUtils.clean();
});
it("should login the user via the login function", () => {
const component = mount();
const controller = TestUtils.getControllerOf(component.instance());
const user = controller.login('[email protected]', 'myP@sswd');
expect(user).toEqual({
email: "[email protected]",
username: 'user'
});
});`

React: 16.8.6
Controllerim: 1.62.0
Jest: 24.7.1

Wrong controller retrieved in Production build

Hello,

After a production build yarn build, controllerim returns the wrong controller.

The following scenario is based on the code available here.

Do not hesitate if you have any question.

It is the first time I use controllerim so I may have missed something.

Have a good day,

Scenario

Dev environment (OK)

Run yarn start and open http://localhost:3000.

Open the DevTools console to see the following traces:

OK  HeaderComponent.js:19
OK  MenuComponent.js:19
OK  MenuComponent.js:28

Prod environment (KO)

Run yarn build then serve -s build
Open http://localhost:5000.

Open the DevTools console to see the following traces:

OK  HeaderComponent.js:19
OK  MenuComponent.js:19
KO  MenuComponent.js:31

Controllers tree

ApplicationController
|
|- HeaderController
   |
   |- MenuController

First analysis

Controllerim uses constructor.name as key for controllers.
In this example, after the minification process, the controllerName value is equal to "t" for every controller.

So in the MenuComponent, the this.controller.getParentController(HeaderController.name) is equivalent to this.controller.getParentController('t').
In the getControllerFromContext function of controllerim, this name is used to find the related controller and return the first one which match this name.
In our case, it will be ApplicationController whereas we want to retrieve the HeaderController and so the following verification failed.

if(headerController.iAmHeaderController) {
    console.log('OK');
}
else {
    console.error('KO');
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.