Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

React and ReactDOM were only recently split into two different libraries. Prior to v0.14, all ReactDOM functionality was part of React. This may be a source of confusion, since any slightly dated documentation won't mention the React / ReactDOM distinction.

As the name implies, ReactDOM is the glue between React and the DOM. Often, you will only use it for one single thing: mounting with ReactDOM.render(). Another useful feature of ReactDOM is ReactDOM.findDOMNode() which you can use to gain direct access to a DOM element. (Something you should use sparingly in React apps, but it can be necessary.) If your app is "isomorphic", you would also use ReactDOM.renderToString() in your back-end code.

For everything else, there's React. You use React to define and create your elements, for lifecycle hooks, etc. i.e. the guts of a React application.

The reason React and ReactDOM were split into two libraries was due to the arrival of React Native. React contains functionality utilised in web and mobile apps. ReactDOM functionality is utilised only in web apps. [UPDATE: Upon further research, it's clear my ignorance of React Native is showing. Having the React package common to both web and mobile appears to be more of an aspiration than a reality right now. React Native is at present an entirely different package.]
3 years ago
When I'm converting from JSX to TSX and we keep some libraries as js/jsx and convert others to ts/tsx I almost always forget to change the js/jsx import statements in the TSX\TS files from
***
import * as ComponentName from "ComponentName";
***
to
***
import ComponentName from "ComponentName";
***
If calling an old JSX (React.createClass) style component from TSX, then use
***
var ComponentName = require("ComponentName")
***
3 years ago
If you are trying to add arguments to a handler in recompose, make sure that you're defining your arguments correctly in the handler. It is essentially a curried function, so you want to be sure to require the correct number of arguments. This page has a good example of using arguments with handlers.

Example (from the link):
***
withHandlers({
handleClick: props => (value1, value2) => event => {
console.log(event)
alert(value1 + ' was clicked!')
props.doSomething(value2)
},
})
***
for your child HOC and in the parent
***
class MyComponent extends Component {
static propTypes = {
handleClick: PropTypes.func,
}
render () {
const {handleClick} = this.props
return (

)
}
}
***
this avoids writing an anonymous function out of your handler to patch fix the problem with not
3 years ago
You can set this in /etc/systemd/journald.conf like so:
***
SystemMaxUse=100M
***
3 years ago
If your program is already running you can pause it with Ctrl-Z, pull it into the background with bg and then disown it, like this:
***
$ sleep 1000
^Z
[1]+ Stopped sleep 1000
$ bg
$ disown
$ exit
***
3 years ago
pushd and popd allow you to manipulate the directories on stack.

When you pushd a directory, you put the current directory on the stack and change directory to the one specified as a parameter.

popd will allow you to go back to the directory on the stack.

If you repeat, the directory traversal will be sort of preserved and you can come back to the saved directories in reverse order from what you saved them in.
3 years ago
Since it hasn't been explicitly stated, I'll add that there is no better programming environment (Lisp in a box, SLIME, etc.) than a slightly modified Emacs distribution. All of my programming needs (99%) are taken care of from within Vim, but for all those Lisp libraries and routines I write, I have to fire up Emacs to get anything productive done.
3 years ago
C is the default locale,"POSIX" is the alias of "C". I guess "C" is derived from ANSI-C. Maybe ANSI-C define the "POSIX" locale.
3 years ago
You use PHP_EOL when you want a new line, and you want to be cross-platform.

This could be when you are writing files to the filesystem (logs, exports, other).

You could use it if you want your generated HTML to be readable. So you might follow your
with a PHP_EOL.

You would use it if you are running php as a script from cron and you needed to output something and have it be formatted for a screen.

You might use it if you are building up an email to send that needed some formatting.
3 years ago
Sending headers earlier than the normal course may have far reaching consequences. Below are just a few of them that happened to come to my mind at the moment:

While current PHP releases may have output buffering on, the actual production servers you will be deploying your code on are far more important than any development or testing machines. And they do not always tend to follow latest PHP trends immediately.

You may have headaches over inexplicable functionality loss. Say, you are implementing some kind payment gateway, and redirect user to a specific URL after successful confirmation by the payment processor. If some kind of PHP error, even a warning, or an excess line ending happens, the payment may remain unprocessed and the user may still seem unbilled. This is also one of the reasons why needless redirection is evil and if redirection is to be used, it must be used with caution.

You may get "Page loading canceled" type of errors in Internet Explorer, even in the most recent versions. This is because an AJAX response/json include contains something that it shouldn't contain, because of the excess line endings in some PHP files.

If you have some file downloads in your app, they can break too, because of this. And you may not notice it, even after years, since the specific breaking habit of a download depends on the server, the browser, the type and content of the file .
3 years ago
Delete Vendor then composer install
3 years ago
The following is the best solution:
***

***
3 years ago