-
-
Save andrekovac/6c6e9026e85b55d04bb61216b34ab2e9 to your computer and use it in GitHub Desktop.
JS BinExample to understand React Native ListView and JS bind() better// source http://jsbin.com/tufoso
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="Example to understand React Native ListView and JS bind() better"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
/******* Example to understand React Native ListView, bind() and currying *****/ | |
"use strict"; | |
function listView(renderRow) { | |
// bind some data to renderRow callback | |
var render = renderRow.bind(null, "REAL DATA FROM ListView", 2); | |
// call the modified callback | |
render(); | |
} | |
var renderRow1 = function renderRow1(myRowDataPlaceHolder, myIdPlaceholder) { | |
console.log("A component with " + myRowDataPlaceHolder + " data, id: " + myIdPlaceholder); | |
}; | |
var renderRow2 = function renderRow2(myRowDataPlaceHolder) { | |
console.log("A component with " + myRowDataPlaceHolder + " data and NO id provided here."); | |
}; | |
// Call renderStuff with callback function 'renderRow' | |
listView(renderRow2); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">/******* Example to understand React Native ListView, bind() and currying *****/ | |
function listView(renderRow) { | |
// bind some data to renderRow callback | |
var render = renderRow.bind(null, "REAL DATA FROM ListView", 2); | |
// call the modified callback | |
render(); | |
} | |
var renderRow1 = function(myRowDataPlaceHolder, myIdPlaceholder) { | |
console.log("A component with " + myRowDataPlaceHolder + | |
" data, id: " + myIdPlaceholder); | |
}; | |
var renderRow2 = function(myRowDataPlaceHolder) { | |
console.log("A component with " + myRowDataPlaceHolder + | |
" data and NO id provided here."); | |
}; | |
// Call renderStuff with callback function 'renderRow' | |
listView(renderRow2);</script></body> | |
</html> |
This file contains hidden or 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
/******* Example to understand React Native ListView, bind() and currying *****/ | |
"use strict"; | |
function listView(renderRow) { | |
// bind some data to renderRow callback | |
var render = renderRow.bind(null, "REAL DATA FROM ListView", 2); | |
// call the modified callback | |
render(); | |
} | |
var renderRow1 = function renderRow1(myRowDataPlaceHolder, myIdPlaceholder) { | |
console.log("A component with " + myRowDataPlaceHolder + " data, id: " + myIdPlaceholder); | |
}; | |
var renderRow2 = function renderRow2(myRowDataPlaceHolder) { | |
console.log("A component with " + myRowDataPlaceHolder + " data and NO id provided here."); | |
}; | |
// Call renderStuff with callback function 'renderRow' | |
listView(renderRow2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment