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
import React from 'react'; | |
import CompenentWeNeedToPassPropsTo from './CompenentWeNeedToPassPropsTo'; | |
import giveMeYourProps from './giveMeYourProps'; | |
export default class MainComponent extends React.Component { | |
// ... | |
render() { | |
return giveMeYourProps(CompenentWeNeedToPassPropsTo, {awesomeName: 'Buz'}); | |
} |
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
import React from 'react'; | |
export default function giveMeYourProps(ComponentToPassPropsTo, propsToPass) { | |
return class PropsPasser extends React.Component { | |
render() { | |
return <ComponentToPassPropsTo {...propsToPass} />; | |
} | |
}; | |
} |
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
import React from 'react'; | |
import MyAwesomeComponent from './MyAwesomeComponent' | |
export default class PassTheProps extends React.Component { | |
// ... | |
render() { | |
return ( | |
<MyAwesomeComponent awesomeName="Buz" /> | |
); | |
} |
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
//when the button on the page is clicked the ajax request will be made | |
$('button').click(function(event){ | |
event.preventDefault(); //prevents browsers default behavior | |
//make the ajax request | |
$.ajax({ | |
url: https:'//api.github.com/users/twolfe2', //url could be first parameter to $.ajax instead | |
data: { | |
format: 'json'//tells github we want our data in json format | |
}, | |
error: function (){ |
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> | |
<script> | |
//step 1 | |
var request = new XMLHttpRequest(); | |
//step 2, create the callback funciton | |
request.onreadystatechange = function() { |