Wednesday, September 26, 2018

React JS set focus on a input

Use the prop autoFocus in a input to make it auto focus

eg:

<input autoFocus className="btn" type="text" />

Monday, September 17, 2018

Recharts - Show dashed line

If you need to show dashed line for a line chart use the below code.

<Line type="linear" dataKey="trend" strokeDasharray="3 3"
stroke="#69C568" dot={{strokeDasharray: 'none'}} />


You need to add property strokeDasharray="3 3" to the <Line /> You can change the values if needed.

The legend dots will also be plotted as dotted lines. If you want to remove that use the dot prop.

dot={{strokeDasharray: 'none'}}

React JS send custom parameter to onClick

If you need to send a custom parameter to your onClick event handler, do like this

<a href="" onClick={()=> {this.tabClicked("Exceptions")}}>Exceptions</a>

if you need to pass the event as well to the onClick handler use like this

<a href="" onClick={(evt)=> {this.tabClicked(evt,"Exceptions")}}>Exceptions</a>


and in your tabClicked() you can get the parameters like this

tabClicked(evt, tab) {
evt.preventDefault(); // Let's stop this event.
alert(tab); // should alert Exceptions
}

Get Indian financial year based on date

This function lets you get the start and end date of Indian financial year based on given date. This can also be modified for US financia...