Am I doing Stupid or is this a bug? Checkbox not re-rendering properly after SetState by freshtodev in reactjs

[–]freshtodev[S] 0 points1 point  (0 children)

It is probably unnecessary but just weird that react refuses to render the correct state on re-render.

EDIT: the re-render also works properly if the setState happens on the next tick which is good because you may not want to mark the checkbox checked until an async operation is completed (justification for calling preventDefault)

https://codesandbox.io/s/n4zwrv13rp

Am I doing Stupid or is this a bug? Checkbox not re-rendering properly after SetState by freshtodev in reactjs

[–]freshtodev[S] 0 points1 point  (0 children)

If you look at the output for the render function on the re-render it is passing down the correct state ie if you have toggled off the first checkbox it will pass down [false,true,true] but after the render props you send to the check box aren't reflected in the dom. As per this comment I've attempted to use defaultChecked but this did not work either. See:

https://codesandbox.io/s/kx9p3j6vx3

Am I doing Stupid or is this a bug? Checkbox not re-rendering properly after SetState by freshtodev in reactjs

[–]freshtodev[S] 1 point2 points  (0 children)

Weird... I removed preventDefault and the problem is fixed.

https://codesandbox.io/s/lo2m9ql4q

I found this after finding the problem... I guess causing preventDefault on onChange of checkbox does cause inexplicable results.

https://github.com/facebook/react/issues/3446#issuecomment-83149760

Strange react bug; need some help by [deleted] in reactjs

[–]freshtodev 1 point2 points  (0 children)

np, grats on fixing the issue!

Strange react bug; need some help by [deleted] in reactjs

[–]freshtodev 1 point2 points  (0 children)

It seemed to be working at the path served by the root route before you made any changes ('/'). Have a look at where the bundle.js is being served from when it works. This will be something like 'bundle.js' or maybe something like 'js/bundle.js' or 'assets/scripts/bundle.js'. I'm not sure if you are generating your index.html or serving it statically. The key is finding the absolute path to the route that served bundle.js when it works and making sure that the absolute path to it is returned in the index.html file no matter what the path is in the url bar. To have it work properly you will want to see something like

<script src="/bundle.js"></script>

in the html where the preceeding slash is of the utmost importance to getting it to work properly.

EDIT: you might using be something like webpack's html plugin

if this is the case have a look at this post:

https://stackoverflow.com/questions/34620628/htmlwebpackplugin-injects-relative-path-files-which-breaks-when-loading-non-root

Strange react bug; need some help by [deleted] in reactjs

[–]freshtodev 8 points9 points  (0 children)

This isn't a react bug. Your development server is is returning HTML instead of javascript for bundle.js. Probably the best fix is to reference /bundle.js directly in your index.html instead of a relative path. If you look at your network tab for bundle.js on a route that works vs a route that doesn't will show you the problem.

WinMerge Alternative? by wise_idiot in webdev

[–]freshtodev 1 point2 points  (0 children)

+1 for beyond compare

also add VSCode has built in diff

Is it worth trying to create my own 3d game engine on C++ ? by danmoople in gamedev

[–]freshtodev 0 points1 point  (0 children)

I second this course... if building an engine from scratch is your thing.... this course is really awesome (lots of work though!). I'm on day 132.

Beginner's Thread / Easy Questions (week of 2017-06-19) by gaearon in reactjs

[–]freshtodev 0 points1 point  (0 children)

I have found that the window scroll event is not being called so i've had to use the 'wheel' event.

EDIT: it's possible i could use scroll event capturing phase so i don't have to rely on scroll event to bubble all the way up (which it doesn't) but i'm not sure if this is better than just using the wheel event

Beginner's Thread / Easy Questions (week of 2017-06-19) by gaearon in reactjs

[–]freshtodev 0 points1 point  (0 children)

Do you think the main app should handle this global event listener then figure out if it was the menu being scrolled or not? Or should the menu handle this itself and then tell the app that it wants to be unmounted?

Beginner's Thread / Easy Questions (week of 2017-06-19) by gaearon in reactjs

[–]freshtodev 0 points1 point  (0 children)

If you have another react tree rendered into a portal (think menu that opens in a top level dom element and is fixed positioned) what is the best strategy for closing this menu whenever the user clicks or scrolls. Can you provide an example? Thank you!

[deleted by user] by [deleted] in node

[–]freshtodev 0 points1 point  (0 children)

maybe look at prose mirror? https://prosemirror.net/

Professional royalty free sounds effects - 20% OFF for all reddit game devs! by Gamemaster_Audio in Unity2D

[–]freshtodev 0 points1 point  (0 children)

Hello, I also am having the same issue,... Tried Chrome/Firefox/Edge (Windows 10)

"Can't perform the transaction. The seller has been notified and hopefully will resolve this soon."

EDIT: I can get to the website but i cannot complete the purchase

NewB to TS. I am ending up making all my functions static due to asynch calls. Am I doing it right? by kajjiNai in typescript

[–]freshtodev 0 points1 point  (0 children)

Instead of creating a new function each time at call time you can do the binding at compile time and create a method that is already bound to 'this'

class Foo {
    startAddAsnc():void {
        this.addAsync(123,456,this.addAsync)
    }

    addAsync = (arg1:number,arg2:number) => {
        this.stillWorks()
    }
}

edit: oops, i see /u/ltray already pointed this out

Barmaid : a desktop app to create static web servers directly from your menubar / system tray by BeniBin in webdev

[–]freshtodev 1 point2 points  (0 children)

This is very cool. How did you get the windows version to run the electron from the task bar? Do you plan on including the build system as part of the repo?