visual studio - typescript+reactjs+ requirejs: how to import react-dom into typescript -


i using typescript + react.js. in visual studio (2015) , in project properties --> typescript build --> module system: have checked amd using requirejs import modules.

i have main.txs file render main component body tag, thing like:

react.render(<mymaincomponent />, my_body_element); 

now on top of file have made proper import statements:

import react = require('react'); import reactdom = require('react-dom');  import some_library = require('./some_library') 

(sos: using definitelytyped -tsd- import type definitions)

after build (in visual studio) there main.js file generated javascript emitted followed:

define(["require", "exports", 'react', './some_library'], function (require, exports, react, some_library) {   ..... code goes here .....  } 

you can see require statement react-dom has not been generated. why require statement react-dom not generated within emitted main.js file?

the consequence not able use reactdom in code.

has 1 been able use react, react-dom, requirejs , typescript? (presumably in visual studio environment?)

how can tell visual studio emit require statement react-dom?

if code wrote

react.render(<mymaincomponent />, my_body_element); 

then you're not using reactdom, compiler thinks it's safe remove import.

you want write

reactdom.render(<mymaincomponent />, my_body_element); 

if there's else going on want import react-dom not use (why?), use amd-dependency tag explicitly add imports list.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -