I'm working on a new project and am very new to React. We are using typescript(TSX). So far I have an index.html file with a div with an id of 'root'. I have a main.tsx file which I believe is for my main component. here is the code for that
/// <reference path="../../../../typings/main.d.ts"/>
require('file?name=[name].[ext]!../../index.html');
/*----------- STYLESHEETS -----------*/
require('flexboxgrid/css/flexboxgrid.css');
/*=============================================>>>>>
= MODULES =
===============================================>>>>>*/
import * as React from 'react';
import { render } from 'react-dom';
import { Router, Route, IndexRoute, browserHistory } from 'react-router';
/*----------- ROUTE COMPONENTS -----------*/
import Root from './common/root.tsx';
import Home from './home/home.tsx';
import Login from './login/login.tsx';
//
// /*= End of MODULES =*/
// /*=============================================<<<<<*/
render((
<Router history={browserHistory}>
{/** ###### HOME ROUTE ###### */}
<Route path="/" component={Root}>
<IndexRoute component={Home}/>
<Route path="/login" component={Login}/>
</Route>
{/** ###### END HOME ROUTES ###### */}
</Router>
), document.getElementById('root'));
I'm unsure of how to do my root.tsx file so that it shows up inside my root div. This is what I have so far for my root.tsx file.
"use strict";
import React from 'react';
class Root extends React.Component {
render() {
return(
<div>
<h1>About page!</h1>
</div>
)
}
}
export default Root;
import React from 'react'toimport * as React from 'react';in your root.tsx