Textarea Auto height

It can be achieved using JS. Here is a ‘one-line’ solution using elastic.js: Updated: Seems like elastic.js is not there anymore, but if you are looking for an external library, I can recommend autosize.js by Jack Moore. This is the working example: Check this similar topics too: Autosizing textarea using Prototype Textarea to resize based on content length Creating … Read more

var.replace is not a function

My guess is that the code that’s calling your trim function is not actually passing a string to it. To fix this, you can make str a string, like this: str.toString().replace(…)…as alper pointed out below.

How to interpolate variables in strings in JavaScript, without concatenation?

You can take advantage of Template Literals and use this syntax: Template literals are enclosed by the back-tick (` `) (grave accent) instead of double or single quotes. This feature has been introduced in ES2015 (ES6). Example How neat is that? Bonus: It also allows for multi-line strings in javascript without escaping, which is great for templates: Browser support: … Read more

Pass react component as props

Using this.props.children is the idiomatic way to pass instantiated components to a react component When you pass a component as a parameter directly, you pass it uninstantiated and instantiate it by retrieving it from the props. This is an idiomatic way of passing down component classes which will then be instantiated by the components down … Read more