Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you still write HTML/CSS files if you're using React.js?

I can't seem to understand the workflow with react.js. Do you still need to write HTML and CSS straight up?

like image 878
TheGreyBearded Avatar asked Apr 23 '17 04:04

TheGreyBearded


People also ask

Do you still write HTML with React?

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.

Do you write CSS in React?

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.

Do React developers write CSS?

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.

Does React use HTML files?

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.


1 Answers

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

  1. 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

  2. As styled component, in this case you code css as a JSON inside your javascript file

like image 142
Evandro Cavalcate Santos Avatar answered Nov 15 '22 05:11

Evandro Cavalcate Santos