score:1
you can write react code simply by loading the react libraries through <script>
tag in the <head>
element, as long as you select the html element in your react code
for example if you wanted to code a like button in react, in html you give a unique id:
<div id="like_button_container"></div>
then, in javascript you select the element and render with react:
const domcontainer = document.queryselector('#like_button_container');
reactdom.render(e(likebutton), domcontainer);
full example can be found here by dan abramov: https://gist.github.com/gaearon/6668a1f6986742109c00a581ce704605
so in webpack, we'll just have to find ways to add the <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
to the <head>
element somehow. depends how you've set up your index.html
, you can either 1) add the script tag directly into index.html
or 2) use plugins such as html-webpack-pluign to dynamically generate the index.html
Source: stackoverflow.com
Related Query
- How to add react to an existing express multipage project with ejs?
- How to add React components to existing Django project
- How to add react with typescript to existing asp.net core mvc application
- How should I add Redux to a React project created with Create-React-App?
- How to add express backend to existing react app
- How to add "refs" dynamically with react hooks?
- How to upgrade a React project built with create-react-app to the next create-react-app version?
- How to add jsconfig.json to existing vscode project w/o breaking it
- How to add global loading/spin effect in axios interceptor for a React project
- How to add new elements without re-rendering whole list with React
- How to handle React Router with Node Express routing
- How can I apply Next.js to a React project created with create-react-app?
- How to add click event with React createElement
- how to add type declaration to react-typescript project with CRA
- How to use Antdesign with tailwindcss together in a React Project
- How to add components to list dynamically in React with no redundant render?
- How to use Turborepo for an existing react app created with Create React App in order to make it a monorepo?
- How to add login authentication and session to ReactJS React Router and Redux with MongoDB + NodeJS Express?
- How to Add React Js On an Existing Website?
- How to integrate React Native to existing iOS project
- How to display all options in react bootstrap typeahead menu with existing selection
- How to add sorting to table with react virtualized?
- How to run an existing REACT project
- How to create a react project with specific version of create-react-app?
- How to add styling to a React project
- How to Merge React App into existing Website with existing HTML structure
- How do I show the Google passport oAuth consent screen in the react frontend, not with express views template
- How to add es2020 features to existing react app?
- Deploying React + Express App to Kubernetes. How to structure it with docker?
- How do I integrate React with a non-trivial AngularJS app and existing grunt configurations?
More Query from same tag
- `Cannot read properties of undefined` for enum after bundling with webpack
- Change the color of calendar dates (react big calendar)
- Pagination not working in react js as I dont know which parameter should be passed
- Passing Data between REACT sibling component
- Why is the download button using anchor tag in react js not working?
- How to distribute fonts or other static assets with a React component library built using Webpack?
- How to correctly use compose to combine HOCs that encapsulate protected routes in React-Redux
- React: Passing props between components is always undefined - Context API
- Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware with redux tool
- redux-form dynamic wizard
- How to use promises in javascript ? Basic Promise in Javascript
- Redux Thunk + Axios "Actions must be plain objects. Use custom middleware for async actions."
- react leaflet -layer control -satellite view
- How can I change ReactJS Project (folder) name?
- Yup with Formik, LessThan or Equal
- How to call a function which has a same name with a parameter
- Dispatching action from onUploadProgress event using Redux-Thunk / Axios
- react-select:: Type '{ label: string; value: string; }' is missing the following properties from type 'readonly never[]'
- Modify the markup for markers on the SVG map
- React material design function call automatically on page onload instead on onclick
- how to show details page using react router dom
- Accessing data and displaying in a dropdown
- How to properly handle unauthenticated users and requests in AWS Amplify/AppSync React apps?
- How to deal with the dependency between two async thunks
- Why does mapping a React hook work, but a lambda violates rule of hooks?
- Adding a radio button value to parent component in react
- Material design React List orientation
- how to make google bots crawl my react website with dynamic urls and display them in google
- Mocha test of React component which uses System.js to handle css import
- I can not return data with useSelector in react redux