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

search: ked dost rychlo kliknem na highlighnuty search result: Warning: setState(...): Can only update a mounted or mounting component. #39

Closed
petervojtek opened this issue Mar 12, 2017 · 9 comments
Assignees
Labels

Comments

@petervojtek
Copy link
Member

warning.js:36 Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the ReactClass component.

postup:

  1. treba ist kurzorom na nejaky search result
  2. a ihned nan kliknut
@petervojtek
Copy link
Member Author

Martin @zdila , zda sa mi ze ten problem sposobila tato zmena v organizacii headeru v main, ktora sposobuje ze Search komponent sa remountuje po kazdej zmene tool-u.

a to zretazenie ternarnych operatorov je podla mna dost nestastny napad.. je to zle zrozumitelne :(

@zdila zdila self-assigned this Mar 13, 2017
@zdila zdila closed this as completed in 1e67b7e Mar 13, 2017
@zdila
Copy link
Member

zdila commented Mar 13, 2017

Pravda, react nevie, ze to je iny komponent, tak ho vytvori znova (facebook/react#3965). Opravil som to.

Inac zapis:

cond1 ? result1
  : cond2 ? result2
  : cond3 ? result3
  : result4;

je podla mna citatelny. Ale tu je jeho prepis ak ti toto pride citatelnejsie:

() => {
  switch (tool) {
    case 'a':
      return <A/>;
    case 'b':
      return <B/>;
    default:
      return <C/>;
  }
}()

@petervojtek
Copy link
Member Author

vdaka za fix.

switch je podla mna rovnako zly ako zretazeny ternarny operator (switch radsej vobec nepouzivam) -- podla mna je najlepsi obycajny if (bez zbytocnych krutenych zatvoriek :)

inak udivuje ma, ze tento problem frameworky uz davno vyriesili, len react znovyvymysla hranate koleso :), napr. v angulare by to bolo uplne jednoduche a prehladne:

<Search *ngIf="tool == 'search'" />

@zdila
Copy link
Member

zdila commented Mar 13, 2017

Zase davas zle porovnanie.

Aj v angulari by to muselo byt: <Search *ngIf="tool !== 'objects' && tool !== 'route-planner'" />

V reacte je to teraz: {tool !== 'objects' && tool !== 'route-planner' && <Search/>}

@zdila
Copy link
Member

zdila commented Mar 13, 2017

switch je podla mna rovnako zly ako zretazeny ternarny operator

dost subjektivny nazor :-)

Vyhoda switchu je ze porovnavas jednu hodnotu s ostatnymi. Naproti tomu v if/else-if/else moze byt kazda podmienka ina, takze je to zlozitejsia konstrukcia.

@petervojtek
Copy link
Member Author

mas pravdu, ale ani jedno z toho nie je switch case. obe su implicitne if-y.

switch je problematicky preto, lebo mu rozumie menej programatorov, a ked pouzivas viac programacich jazykov, niekdy nevies ci tam nechyba nejaky break a aka je presne syntax. if je silny najma vtedy, ked si nehadzes polena pod nohy lint pravidlom ze aj pri jednoriadkovo obsahu if-u musia byt krutene zatvorky :)

@zdila
Copy link
Member

zdila commented Mar 13, 2017

switch je problematicky preto, lebo mu rozumie menej programatorov

Toto ma nepresvedci aby som to prestal pouzivat. Ak robi programator v javascripte, musi povinne rozumiet vsetkym jeho konstruktom. A switch/case je v C, PHP, Java, C# a rozne obdoby v inych jazykoch.

@petervojtek
Copy link
Member Author

no, z mojej skusenosti je najlepsie pisat co najjednoduchsi kod (najpr. pouzivat iba if a nie switch a ternarny operator),lebo potom dokaze po tebe prevziat kod iny clovek rychlejsie, a takisto tym znizis latku pre novych prispievatelov, co je pri opensource projekte podla mna vyhoda. napriklad tym ze sme zvolili react a redux sme podla mna odpisali vsetkych ktori co i len teoreticky mohli prispiet do codebase freemap v3-- lebo vacsina z potencialnych kandidatov nanajvys rozumie html a jquery, ale react sa kvoli freemap 3 ucit nebudu.

@zdila
Copy link
Member

zdila commented Mar 13, 2017

Tak to sme mali ostat pri plain JS (ECMA Script 5), jquery a PHP na serveri. Tomu rozumie najviac ludi. Ziaden babel ani nic :-). Co vychadza ze sme mali dalej lepit sucastny freemap portal ;-).

Ale moj nazor je, ze programatora, ktory sa nezvladne (nema ochotu) naucit technologie, ktore su sucasne trendy, nechcem na projekte ani vidiet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants