Skip to content

Instantly share code, notes, and snippets.

Created September 9, 2016 12:01
Show Gist options
  • Save anonymous/02fafe085af29555462e75ee8b376fb2 to your computer and use it in GitHub Desktop.
Save anonymous/02fafe085af29555462e75ee8b376fb2 to your computer and use it in GitHub Desktop.
JS Bin Example to understand React Native ListView and JS bind() better // source http://jsbin.com/tufoso
<!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>
/******* 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