0

I want to add an script (react component) for a site which is not created with a ReactJS basis but html and dom manipulation. I want to do it with react since the component is going to operate some logic and also it is going to have some kind of state. I've never created a react feature for a website not running with react entirely. Do you think adding a react feature to an existing app is a good idea at all? And if it is, which is the best way to add some style to this script feature?

https://reactjs.org/docs/add-react-to-a-website.html It covers how to solve this problem using babel but what about styles and css?

2 Answers 2

1

Regarding whether it's a good idea we get this per the official React Docs:

React has been designed from the start for gradual adoption, and you can use as little or as much React as you need. Perhaps you only want to add some “sprinkles of interactivity” to an existing page. React components are a great way to do that.

Here's their approach to adding limited React functionality to non-React pages without any build tooling, just pure HTML DOM.

As for personal opinion, which is veering off-topic, I've only done full pages in React bolted on to non-React websites. Though those worked fine, Mosè Raguzzini may be right in that it's too much hassle/overhead if it can be handled with vanilla JS.

Sign up to request clarification or add additional context in comments.

Comments

0

You can import styles in multiple way:

Notice that if you are not moving to API or you do not need react features a refactor from vanilla javascript to react could be a unuseful pain.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.