我想使用Johnny-Five並創建一個與React JS的接口。使用Johnny-Five與React
我用這個React setup tutorial。我在同一個項目中安裝了Johnny-Five:http://johnny-five.io/(Johnny-Five在單獨的應用程序中獨立工作,這使我可以控制我的Arduino)。
我的陣營index.js:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import MainRouter from './routes';
import registerServiceWorker from './registerServiceWorker';
import five from 'johnny-five';
var board = new five.Board({
port: "/dev/ttyACM0"
});
board.on("ready", function() {
var led = new five.Led(13);
led.blink(500);
});
ReactDOM.render(<MainRouter />, document.getElementById('root'))
registerServiceWorker();
當我運行反應,該網站啓動,但董事會沒有反應!雖然沒有React的代碼工作得很好。任何想讓Johnny-Five與React一起工作的想法?
當你說相同的代碼沒有React時,你的意思是它可以從你的瀏覽器中運行嗎?或者你是通過與NodeJS的控制檯運行它? – Spidy