K
K
KlassT2016-09-29 23:47:22
JavaScript
KlassT, 2016-09-29 23:47:22

How to include a library in React?

In the header I connect react

<script type="text/javascript" src="/js/react.min.js"></script>
<script type="text/javascript" src="/js/react-dom.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/browser.min.js"></script>

Installed the library via npm install
Trying to connect:
import { Parallax } from 'react-parallax';
Error pops up: Uncaught ReferenceError: require is not defined
Apache server

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2016-09-30
@SPAHI4

For ease of getting started, I recommend not to bathe and install one of the dozens of existing boilerplates. For example, https://github.com/facebookincubator/create-react-app
And then figure out how everything works

V
Vladimir Sergeevich, 2016-09-29
@VladimirZhid

Here you need either browserify or webpack. I advise Webpack
It will be both correct and easier, even if you include require.js, at the time the code is executed, the module is not loaded yet, but fiddling with events, etc. I do not recommend

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question