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, { Component, createContext } from 'react'; | |
import PropTypes from 'prop-types'; | |
const ExampleContext = createContext({ api: 'lorem ipsum' }); | |
/* | |
* This is an example when we can't access this.context as the Context component | |
* has been upgraded to use the new API while the Legacy component is relying on the old one. | |
*/ | |
class Legacy extends Component { |
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, { Component, createContext } from 'react'; | |
import PropTypes from 'prop-types'; | |
const ExampleContext = createContext({ api: 'lorem ipsum' }); | |
class New extends Component { | |
static contextType = ExampleContext; | |
render() { | |
const { name } = this.props; |
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, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
class Legacy extends Component { | |
render() { | |
const { name } = this.props; | |
const { api } = this.context; | |
return ( | |
<div> | |
<h1>Hello, {name}</h1> |
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
<html> | |
<head> | |
<title>JS Sandbox</title> | |
</head> | |
<body> | |
<script> | |
const object = { | |
test: "test", | |
paul: "paul", | |
morning: { test: "test", paul: "paul" } |
NewerOlder