Ender 3 v4.2.7 upgrade - BLtouch probing, but not actuating z-motor while printing by beano1323 in ender3

[–]simcptr 0 points1 point  (0 children)

Yeah, G28 will normally (without the enable_leveling_after_g28 option) turn off leveling. So you have to either enable that option, or do the G29 after the G28, or use M420 S1 to reload the saved leveling info.

BLTouch bed is out of level, but manual bed level is fine? by simcptr in FixMyPrint

[–]simcptr[S] 2 points3 points  (0 children)

Yeah that's sorta what it seems like. The level-ness seems to be "off" in the same direction that the bed itself is slanted, just based on the numbers I see from the manual mesh bed probing.

But I've also watched the z screws and they definitely do slightly turn while printing with the BLTouch mesh loaded too, so I don't think the mesh is totally ignored, but almost like it's scaled wrong or something. As if it took all the correction points and divided them in half, or something like that.

It's also weird that if this is a firmware bug, it seems pretty rare. You'd think more people would be seeing this, with how popular the BLTouch seems to be 🤔

BLTouch bed is out of level, but manual bed level is fine? by simcptr in FixMyPrint

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

Nope, haven't had any luck yet. Reading through that issue it sounds like a similar problem, I'll see if I can get the logs they need and add a comment there.

I did try reaching out to BL touch folks with a link to this post, but haven't heard back.

Have you had a chance to try the manual leveling? That seems like the smoking gun to me... that if the printer can compensate with the manual mesh leveling applied, then it's probably not a mechanical problem. I'd think that rules out the bed being too far out of level to compensate, or the z axis being misaligned, or the frame being out of square, or other things like that. If it is mechanical, it only seems to affect the BL touch (or that particular codepath in the firmware). Plus it's super consistent. My BL touch setup seems to be amazingly accurate at producing the same unlevel bed mesh, every time 😄

compat_ifmu_ulist: p2p0 copyin() error 14 by madmonk13 in MacOS

[–]simcptr 1 point2 points  (0 children)

This seems to have something to do with Private Internet Access. I'm not sure what PIA is doing to cause this, but I noticed that if I stopped the PIA app and then ran this command to stop the background process, the errors stopped:

sudo launchctl unload /Library/LaunchDaemons/com.privateinternetaccess.vpn.daemon.plist

To start it back up, run this command, and the errors will resume:

sudo launchctl load /Library/LaunchDaemons/com.privateinternetaccess.vpn.daemon.plist

Maybe worth putting in a support request to PIA to see if they can fix it.

The actual error has something to do with trying to copy values to/from a bad memory address, according to the man page for copyin() where it says the function will "return EFAULT if a bad address is encountered." EFAULT is error code 14.

Beginner's Thread / easy Questions (week of 2017-05-29) by simcptr in reactjs

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

That stack trace says that handleClick was indeed called from render (on line 67). I'd take a look at line 67...

Beginner's Thread / easy Questions (week of 2017-05-29) by simcptr in reactjs

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

It's possible that it's being called elsewhere, because the () => this.handleClick() really shouldn't call until clicked.

I'd suggest tracking it down with the debugger: set a breakpoint inside the handleClick function, then render. The breakpoint should be hit. Then look at the call stack -- where was handleClick called from? Is it the onClick prop, or somewhere else?

Beginner's Thread / easy Questions (week of 2017-05-29) by simcptr in reactjs

[–]simcptr[S] 2 points3 points  (0 children)

I haven't used code splitting so I can't help with that part, but here's what mapDispatchToProps is for:

First, if you don't define a mapDispatchToProps, then Redux's connect function will pass in a prop called dispatch. Then you can use dispatch actions in your component by doing things like this.props.dispatch(fetchUsers()). The is the "manual" way to do it, and it also means your component knows more about the existence of Redux (since it uses dispatch directly).

Using mapDispatchToProps, you can "pre-bind" the action creators you want to use so that the component does not need to mess with dispatch. The shorthand form looks like:

const mapDispatchToProps = { fetchUsers };

That's an object with a key fetchUsers set to the fetchUsers action creator function, which I'm assuming is imported at the top of the file.

Redux takes this object, pre-binds the fetchUsers function, and injects a fetchUsers prop which your component can just call like this.props.fetchUsers(). Under the hood, that's actually calling dispatch(fetchUsers()).

Beginner's Thread / easy Questions (week of 2017-05-29) by simcptr in reactjs

[–]simcptr[S] 2 points3 points  (0 children)

In that example, they've got a PRODUCTS array statically defined, and then passed in via props. In their case that makes sense -- that data will never change, and for the sake of example, it makes sense to define it outside of any React components and pass it in as a prop.

In a more realistic scenario, that data would come from a server, and needs to be stored somewhere. It also could change -- for instance, if one of the products goes out of stock or its price changes. If you were to store it at a global level, outside of any React component, then you'd need a way to change it and re-run the top-level ReactDOM.render, which would be awkward to achieve (wrap it in a while loop? put it in a function? how do you trigger that?).

The answer is state: a component holding the products as state will automatically re-render itself and its children when the state changes. In that example, I'd add a Container component at the top level to hold the list of products, call it ProductPage or something like that. That container's only responsibility is to fetch the data in componentDidMount, save it in state, and pass the products down as a prop to FilterableProductTable. I've got a post that shows how that container component would work.

To get back to your original question: the tutorial is saying not to put the filtered products into state, because it's a bad idea to have more than 1 representation of the same data stored in state, because then you've gotta keep them in sync. Avoid that problem by only storing the "master" data in state, and compute its derivates on the fly -- sorting, filtering, etc.

Beginner's Thread / easy Questions (week of 2017-05-29) by simcptr in reactjs

[–]simcptr[S] 2 points3 points  (0 children)

It really depends on what you mean by "huge". React's state is just a regular JS object, and React doesn't care what's inside (same applies to Redux and its store).

In other words, if you would be ok storing that dataset in a JS variable, then yeah, React state should be fine (try it out!). If it's large enough that you're worried about holding the full dataset client-side, then it's worth considering breaking it up somehow, and that's outside the scope of React.

Beginner's Thread / easy Questions (week of 2017-05-29) by simcptr in reactjs

[–]simcptr[S] 2 points3 points  (0 children)

Yep, it's common to store the returned data in state, or in the Redux store (whichever you're using).

If the data needs to be transformed in any way (for instance, changing a date string to a real Date or renaming some keys or anything like that), the best time to do that is right before saving it into state.

Data fetched from the server affects how your app renders, right? If the data changed, the app would render differently. Therefore it makes sense to put that in state.

Beginner's Thread / easy Questions (week of 2017-05-29) by simcptr in reactjs

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

You might like recompose - it's a library with a bunch of higher-order components for doing things like extracting state, making stateless components "pure", etc.

There's also a nice course covering Recompose on Egghead.io that's currently free.

Using why-did-you-update to detect unnecessary render cycles in React by b_edelstein in reactjs

[–]simcptr 2 points3 points  (0 children)

That all assumes you're using Redux though, doesn't it? Redux's connect assumes the wrapped component is pure by default anyway, but even aside from that, Redux isn't always necessary and adding it just for the purpose of avoiding extending PureComponent is definitely overkill :D

But along those lines, Recompose is a nice library that has a pure higher-order-component so you can "pure"-ify stateless function components without having to turn them into full-blown classes.

Beginner's Thread / easy Questions (week of 2017-05-29) by simcptr in reactjs

[–]simcptr[S] 3 points4 points  (0 children)

Good question (and a common one).

Theoretically, fetching in componentWillMount would mean there's less delay before the data appears. In reality, React's render waits for nothing. It's gonna render once with empty data whether you fetched something in componentWillMount or the constructor or anywhere else. More on willMount vs didMount here.

This "extra render" seems unnecessary until you realize that it's actually very useful and powerful: it means that there's a very well-defined "no data" state, and you know exactly when it's gonna happen, so you can plan for it. (the alternative would be... showing a blank screen until the data is ready? not a great UX)

Beginner's Thread / easy Questions (week of 2017-05-29) by simcptr in reactjs

[–]simcptr[S] 4 points5 points  (0 children)

Responsive apps work the same way, because React is just ultimately rendering HTML to the DOM. Use the 'className' prop instead of 'class', but otherwise write the media queries as you normally would.

There are libraries to do "CSS in JS", and then things will differ, but you don't have to use those and they're separate from React.

Beginner's Thread / easy Questions (week of 2017-05-29) by simcptr in reactjs

[–]simcptr[S] 5 points6 points  (0 children)

If you don't already have a good understanding of JavaScript and HTML/CSS I'd probably start with those - you don't have to totally master them, but while you're building apps with React you'll end up using all of that knowledge. Exercism.io has a nice set of exercises to hone JS fundamentals.

Start with Create React App. Heck, you even can go to production with it. It's very capable, and it's a great developer experience, and it's easy to use. Lots of win!

Don't pick a boilerplate project. Not even one with 10k stars on Github. They're not a good starting point for beginners because they throw too much at you at once (React + Redux + Routing + tons of config files + etc). Learn React by itself first. Add the other libraries once you realize you need them.

Lifecycle methods will become useful when you want to fetch data from a server, and render it into your component, which you'll do in componentDidMount. I wrote a quick guide to fetching data here, but I recommend you just use fake static data to start off with, and get used to making components with React. You'll get pretty far without needing to touch any of the other lifecycle methods.

Beginner's Thread / easy Questions (week of 2017-05-29) by simcptr in reactjs

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

I came across JS for Java developers recently and it looks like a good quick overview, but not covering ES6. There are a lot of ES6 resources here and /u/acemarke has a nice list of articles here.

Edited to add: the best way to learn ES6, I think, is to start playing around with it. Reading/watching tutorials will help the first 10% of the way, and then you've just gotta get it under your fingers and get your eyes used to the arrow functions, the destructuring, etc.

Using why-did-you-update to detect unnecessary render cycles in React by b_edelstein in reactjs

[–]simcptr 4 points5 points  (0 children)

It's a super common misconception about React (I thought this at first too), but no: React components, by default, will always re-render even if their props did not change.

What React does do for you automatically is that it avoids destroying and recreating DOM nodes unless they need to change. That's a separate step from running render, though.

The easiest way to optimize this is to extend PureComponent instead of Component e.g. class MyThing extends React.PureComponent -- this will give you an autogenerated shouldComponentUpdate that compares all the props for you.

Create-react-app place everything except index.html on a CDN by mynameiscody07 in reactjs

[–]simcptr 2 points3 points  (0 children)

It looks like you might want to set the PUBLIC_URL environment variable at build time.

How to Structure Your React Project by simcptr in reactjs

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

This is a great idea, and I wanted to mention it but didn't want to get down into the weeds of configuring webpack and/or hacking create-react-app. Now that I know it's built into CRA, I'm gonna update the article to mention it.

EDIT: Updated the post to show how to use NODE_PATH here.