


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
React jsx, a syntax used to build user interfaces in react. It covers the basics of components, props, state, and rendering markup. Examples include a hellomessage component, a timer component, and a todo application.
Typology: Summaries
1 / 4
This page cannot be seen from the preview
Don't miss anything!
JSX?
React components implement a render() method that takes input data and returns what to display. This example uses an XML-like syntax called JSX. Input data that is passed into the component can be accessed by render() via this.props. JSX is optional and not required to use React. Try the Babel REPL to see the raw JavaScript code produced by the JSX compilation step. LIVE JSX EDITOR class HelloMessage extends React.Component { render() { return (
A JavaScript library for building user interfaces Get Started Take the Tutorial
React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable and easier to debug.
Build encapsulated compose them to m Since component lo you can easily pass the DOM.
React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable and easier to debug.
Build encapsulated compose them to m Since component lo you can easily pass the DOM.
JSX? Hello {this.props.name}
In addition to taking input data (accessed via this.props ), a component can maintain internal state data (accessed via this.state ). When a componentʼs state data changes, the rendered markup will be updated by re-invoking render(). LIVE JSX EDITOR RESULT Seconds: 1 class Timer extends React.Component { constructor(props) { super(props); this.state = { seconds: 0 }; } tick() { this.setState(state => ({ seconds: state.seconds + 1 })); } componentDidMount() { this.interval = setInterval(() => this.tick(), 1000 ); } () {
JSX? React allows you to interface with other libraries and frameworks. This example uses remarkable , an external Markdown library, to convert the
Enter some markdown
Hello, world! Get Started Take the Tutorial class MarkdownEditor extends React.Component { constructor(props) { super(props); this.md = new Remarkable(); this.handleChange = this.handleChange.bind(this); this.state = { value: 'Hello, world!' }; } handleChange(e) { this.setState({ value: e.target.value }); } getRawMarkup() { return { __html: this.md.render(this.state.value) }; } () { Hello, world!