Skip to content

Instantly share code, notes, and snippets.

@aslan144
aslan144 / short.js
Created January 25, 2018 13:29
[S_Ract] #react
----------------İMAGE------------
// GOOD
<Image source={require('./my-icon.png')} />;
// BAD
var icon = this.props.active ? 'my-icon-active' : 'my-icon-inactive';
<Image source={require('./' + icon + '.png')} />;
// GOOD
@aslan144
aslan144 / r
Last active January 25, 2018 13:02
[State] setState #reactn
First, whenever you're updating the state based off the previous state (like count in your example), you'll want to use functional setState.
this.setState((currentState) => ({
count: currentState.count + 1
}))
If you don't, you'll most likely run into some issues. https://medium.com/@shopsifter/using-a-function-in-setstate-instead-of-an-object-1f5cfd6e55d1
Second, I don't love that pattern. Can't you just calculate if it's even before you setState?
@aslan144
aslan144 / line
Last active September 17, 2017 00:22
rust #rr
use std::io;
fn main() {
println!("Type something");
let mut line = String::new();
io::stdin()
.read_line(&mut line)
.expect("Failed to read line");
@aslan144
aslan144 / call jquery slide show method
Created March 15, 2012 23:16 — forked from abedsujan/call jquery slide show method
Read All Images from a folder And display slide show.
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script src="jquery.innerfade.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$('#image_rotate').innerfade({
speed: 'slow',
timeout: 2000,
type: 'sequence',
containerheight: '220px'
});