We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import React from 'anujs'; import ReactDOM from 'anujs'; import PropTypes from 'anujs'; class Parent extends React.Component { render() { return (<div className="parent"><Son /></div>) } } class Son extends React.Component { render() { return (<div className="son">{this.context.value}</div>) } } class App extends React.Component { getChildContext() { return { value: 666 }; } render() { return (<div className='app'><Parent /></div>) } }; ReactDOM.render( <App/>, document.getElementById('root') )
在上述代码中,无法获取到{this.context.value}。
{this.context.value}
代码出处:https://rubylouvre.github.io/anu/context.html
The text was updated successfully, but these errors were encountered:
代码运行截图
Sorry, something went wrong.
改了,为了与官方保持一致。
class Parent extends React.Component { render() { return ( <div className="parent"> <Son /> </div> ); } } class Son extends React.Component { static contextTypes = { value: React.PropTypes.number }; render() { return <div className="son">{this.context.value}</div>; } } class App extends React.Component { static childContextTypes = { value: React.PropTypes.number }; getChildContext() { return { value: 666 }; } render() { return ( <div className="app"> <Parent /> </div> ); } } var div = document.createElement("div") ReactDOM.render(<App />, div); expect(div.textContent || div.innerText).toBe("666")
No branches or pull requests
在上述代码中,无法获取到
{this.context.value}
。代码出处:https://rubylouvre.github.io/anu/context.html
The text was updated successfully, but these errors were encountered: