React input defaultValue doesn’t update with state

Another way of fixing this is by changing the key of the input. <input ref=”text” key={this.state.awayMessage ? ‘notLoadedYet’ : ‘loaded’} onChange={this.onTextChange} defaultValue={awayMessageText} /> Update: Since this get upvotes, I will have to say that you should properly have a disabled or readonly prop while the content is loading, so you don’t decrease the ux experience. … Read more

How do I get the Back Button to work with an AngularJS ui-router state machine?

Note The answers that suggest using variations of $window.history.back() have all missed a crucial part of the question: How to restore the application’s state to the correct state-location as the history jumps (back/forward/refresh). With that in mind; please, read on. Yes, it is possible to have the browser back/forward (history) and refresh whilst running a … Read more

Angular UI-Router $urlRouterProvider .when not working when I click

There is a new working plunker (extending the Angular UI-Router $urlRouterProvider .when not working *anymore*), which should be working with the version 0.2.13+ Previous solution Until version 0.2.12- we could use $urlRouterProvider.when(), suggested in documenation (small cite): How to: Set up a default/index child state … if you want the ‘parent.index’ url to be non-empty, … Read more

How to use executables from a package installed locally in node_modules?

UPDATE: As Seyeong Jeong points out in their answer below, since npm 5.2.0 you can use npx [command], which is more convenient. OLD ANSWER for versions before 5.2.0: The problem with putting ./node_modules/.bin into your PATH is that it only works when your current working directory is the root of your project directory structure (i.e. … Read more

Null-safe property access (and conditional assignment) in ES6/2015

Update (2022-01-13): Seems people are still finding this, here’s the current story: Optional Chaining is in the specification now (ES2020) and supported by all modern browsers, more in the archived proposal: https://github.com/tc39/proposal-optional-chaining babel-preset-env: If you need to support older environments that don’t have it, this is probably what you want https://babeljs.io/docs/en/babel-preset-env Babel v7 Plugin: https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining … Read more