score:1
EDIT: I see that you use babel-core
browser.js
, which has been deprecated, remove it and use React directly.
Remove script
type and replace everything with:
var HelloWorld = React.createClass({
render: function() {
return React.createElement("h1", null, "Hello world!!");
}
});
ReactDOM.render(React.createElement(HelloWorld, null), document.getElementById("content"));
score:2
The problem with your first example is that React.renderComponent
is not a function, you need to use ReactDOM.render
instead. You should save yourself a lot of effort now and just use create-react-app and use this application. It takes all of the pain out of the tooling that you will need to make React fast to use (webpack hot module reloading). It is extremely simple compared to the average tooling you will need to setup taking any other route and is made by the people that make React. I can tell by the version number of React that you are using, the tutorial you are going of of is very old, a very longtime before Facebook released create-react-app when things were more difficult.
If you are going to go about it inline, use this in your head -
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react.min.js" integrity="sha256-cLWs9L+cjZg8CjGHMpJqUgKKouPlmoMP/0wIdPtaPGs=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.js" integrity="sha256-M5lc1yUhpXlm2VZjGk4aoFwqR9H1OJ0p5MR5xpipulk=" crossorigin="anonymous"></script>
Full working example on React 15 -
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react.min.js" integrity="sha256-cLWs9L+cjZg8CjGHMpJqUgKKouPlmoMP/0wIdPtaPGs=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.js" integrity="sha256-M5lc1yUhpXlm2VZjGk4aoFwqR9H1OJ0p5MR5xpipulk=" crossorigin="anonymous"></script>
<title>HELLO WORLD</title>
</head>
<body>
<div id="content"></div>
<script>
var HelloWorld = React.createClass({
render: function() {
return React.createElement("h1", null, "Hello world!!");
}
});
ReactDOM.render(React.createElement(HelloWorld, null), document.getElementById("content"));
</script>
</body>
</html>
Source: stackoverflow.com
Related Query
- React this.setState is not a function
- React JS - Uncaught TypeError: this.props.data.map is not a function
- TypeError dispatcher.useState is not a function when using React Hooks
- onclick function is not working in react native application
- Error with basic React Example: Uncaught TypeError: undefined is not a function
- React Native: this.setState is not a function
- React - useState - why setTimeout function does not have latest state value?
- React store.getState is not a function
- React Context: TypeError: render is not a function
- React App - createProxyMiddleware is not a function
- TypeError: environment.setup is not a function in React Testing
- How to fix nextCreate is not a function setting up useMemo setting up authentication react router and hooks
- Uncaught TypeError: create is not a function using useEffect React Hook with AJAX request
- React 16.7 Hooks : `react.useState` is not a function
- React function says "is not a function"
- React TypeError: React.renderComponent is not a function
- React JS Uncaught Reference Error: function not defined
- react function is not defined no-undef
- React Hooks issues in React 16.7 TypeError: Object(...) is not a function
- React TypeError this._test is not a function
- map function not working in React
- React testing library - TypeError: expect(...).toHaveTextContent is not a function
- How to fix TypeError _interopRequireDefault is not a function in Create React App
- React hooks value is not accessible in event listener function
- require function not working with image in react
- React Native - ReactNavigation.addNavigationHelpers in not a function
- React TypeError: x is not a function
- Using JS React component in TypeScript: JSX element type 'MyComponent' is not a constructor function for JSX elements
- React JS : history.push is not a function error and it isn't navigating to a different page onclick of swal
- firebase2.default.firestore is not a function - React Firebase
More Query from same tag
- Return in React the same component but different values
- Delete clicked item of a list fetched from MongoDB
- React.js - ErrorBoundary
- Can not access react props data when I try to access it. Getting TypeError error
- Export (default) class in ReactJS
- How to change style of an element onClick at another element REACT?
- Could not find an open port at x86_64-conda_cos6-linux-gnu
- How to integrate React Native to existing iOS project
- Material Table rowStyle background color change based on cell value in
- "this" avaialable but "this.state" not available
- Child Component is not updating whenever i set the state in reactjs
- How do I wait for a useReducer dispatch to update the state?
- Reactjs TypeError: Class extends value undefined is not a constructor or null
- How do I use jest to test jsx components?
- Problem with Containers - React and Styled Components
- React component not getting rendered each time when state changed
- Update state with value from button element onClick
- React dynamic component not rendering
- React render a component on click after another react component
- ReactJS - How to fix compile error in a chat app?
- Authentication Error when using mode: no-cors using fetch in React
- Same logic but different behaviour in 'class' and in 'functional component'
- Using ReactJS and normal javascript code together
- How to call a function in build time through webpack?
- How to store a values of multiple inputs in the state of a mapping React
- Mapping a list by a function, on click give me error: "Cannot read property 'value' of undefined"
- Heroku ReactJS app. Error when using map function, cannot read properties of undefined
- How to hide updated state from the URL
- How to set Material UI checkbox list checked by default?
- how to reduce the height of cell or row in react?