Reputation: 67
I'm new in ReactJS.
I'm using command "npx create-react-app reactproject" to create a website by using react.But i dont know how to configure page (html or js) as default page when project run? I have googling on this, but not able to get answer.
Thank you.
Upvotes: 1
Views: 15457
Reputation: 83
If you want to change the HTML page the react app renders on you can add the ID "root" to a div and your react app will render within that however i don't recommend it.
Obviously remove root from index.html
I recommend you read React docs https://reactjs.org/docs/getting-started.html
if you meant you want to render a different React component on the home page you can use React Router like so:
<Route path='/' exact={true} component={Home} />
also install React Router via npm and include it:
import { BrowserRouter as Router, Route } from 'react-router-dom';
Upvotes: 0
Reputation: 3760
A react app initialized with create-react-app
starts on the page rendered by ./src/App.js
.
In the render()
function of that file you can create your page and include navigation for other pages.
class App extends Component {
// ...
render() {
return (
<Text>My home page</Text>
);
}
}
Upvotes: 2