This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------İ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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io; | |
fn main() { | |
println!("Type something"); | |
let mut line = String::new(); | |
io::stdin() | |
.read_line(&mut line) | |
.expect("Failed to read line"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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' | |
}); |