Reactjs | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Reactjs

import React from 'react'; import ReactDOM from 'react-dom'; What are "react" and "react-dom"? Where are they located? Can I use components within client side event? Check the click function Could it console log the element instead of the javascript object? function click() { //Executed in the client side console.log(<P/>) } class Button extends React.Component { render() { return <button onClick={click} id="button">button</button> } } class P extends React.Component { render() { return <p>Paragraph</p> } } ReactDOM.render(<Button/>, document.getElementById("root"))

22nd Mar 2020, 6:04 PM
Toni Isotalo
Toni Isotalo - avatar
1 Answer
+ 1
You typically install react with a package manager like npm or yarn, and they work like any other module in that regard. (You can find the react files in the node_modules folder of your project) If you have node.js installed, you can run `npx create-react-app` in your terminal and it will set up everything for you. A component is just a class so you can use it on the client, yes. However, the JSX <Tag /> syntax is not proper javascript so you need to compile it down to regular js before the client can run it. You can do this with `babel` for example. Again, `create-react-app` will set up the build pipeline for you and you can just write react code and see live changes in your browser.
23rd Mar 2020, 12:53 AM
Schindlabua
Schindlabua - avatar