I can't seem to understand the workflow with react.js. Do you still need to write HTML and CSS straight up?
With React, we write HTML using JavaScript. We rely on the power of JavaScript to generate HTML that depends on some data, rather than enhancing HTML to make it work with that data.
Writing CSS in a stylesheet is probably the most common and basic approach to styling a React application, but it shouldn't be dismissed so easily.
At a high level, React developers should be able to: Work with and write semantic HTML tags. Work with and write CSS selectors. Implement a CSS reset.
There may be an instance where you would want to display HTML inside a React Component. The HTML could be from an external source or a file that you want to display to the user. By default, React does not permit you to inject HTML in a component, for various reasons including cross-site scripting.
Yes, do you still have to write HTML and CSS, but you have different workflow for both
HTML you write on render function inside your javascript file, as example below:
const HelloMessage = (props) => {
return (
<div>Hello { props.name }</div>
);
}
ReactDOM.render(<HelloMessage name="Jane" />, mountNode);
CSS you can write in two ways
As css modules, you can code a sass/less/stylus or even css file, then you import inside your javascript file and using classname (npm module) you call it
As styled component, in this case you code css as a JSON inside your javascript file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With