最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - create-react-app running on Smart TV browser - Stack Overflow

programmeradmin2浏览0评论

I am facing a big problem with create-react-app environment on trying to run my application inside a Smart TV browser.

Specification TV and browser ()

  • TV: Panasonic TC-32DS600B
  • Browser: Chrome 23 FreeBSD
  • userAgent: Mozilla/5.0 (X11;FreeBSD;U;Viera:pt-BR) AppleWebKit/537.11 (KHTML, like Gecko) Viera/3.18.1 Chrome/23.0.1271.97 Safari/537.11

Here is what I am trying to:

  1. create a fresh create-react-app project
  2. run yarn build
  3. yarn global add serve && serve -s build
  4. Use my LAN IP (not localhost) and type on url address browser http://<my-lan-ip>:5000 (5000 port as default port provided by serve mand)

When I follow these steps I get a blank page. The blank page only occours in a TV browser. On PC and Mobile runs fine.

So I am wondering and ask here to have some share thoughts:

  1. Old TV browsers doesn't support React?
  2. Or maybe is just a polyfill problem?
  3. Or it doesn't support HTML5, CSS3?

Anyone have already face this problem? Any solution or No, it is not possible?

EDITED: Solution

Thanks to @Rikin and @JoeClay I came up with a solution. First, after download the Chrome version 23, I could see the problem is polyfills (Set and Map).

So after install yarn add core-js --dev and yarn add raf --dev.

Update src/index.js

import 'core-js/es6/map'; // <-- added this line after installed packages
import 'core-js/es6/set'; // <-- added this line after installed packages
import 'raf/polyfill'; // <-- added this line after installed packages

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();

Also, the portion of React Docs which helped to find this solution.

I am facing a big problem with create-react-app environment on trying to run my application inside a Smart TV browser.

Specification TV and browser (http://whatismybrowser.)

  • TV: Panasonic TC-32DS600B
  • Browser: Chrome 23 FreeBSD
  • userAgent: Mozilla/5.0 (X11;FreeBSD;U;Viera:pt-BR) AppleWebKit/537.11 (KHTML, like Gecko) Viera/3.18.1 Chrome/23.0.1271.97 Safari/537.11

Here is what I am trying to:

  1. create a fresh create-react-app project
  2. run yarn build
  3. yarn global add serve && serve -s build
  4. Use my LAN IP (not localhost) and type on url address browser http://<my-lan-ip>:5000 (5000 port as default port provided by serve mand)

When I follow these steps I get a blank page. The blank page only occours in a TV browser. On PC and Mobile runs fine.

So I am wondering and ask here to have some share thoughts:

  1. Old TV browsers doesn't support React?
  2. Or maybe is just a polyfill problem?
  3. Or it doesn't support HTML5, CSS3?

Anyone have already face this problem? Any solution or No, it is not possible?

EDITED: Solution

Thanks to @Rikin and @JoeClay I came up with a solution. First, after download the Chrome version 23, I could see the problem is polyfills (Set and Map).

So after install yarn add core-js --dev and yarn add raf --dev.

Update src/index.js

import 'core-js/es6/map'; // <-- added this line after installed packages
import 'core-js/es6/set'; // <-- added this line after installed packages
import 'raf/polyfill'; // <-- added this line after installed packages

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();

Also, the portion of React Docs which helped to find this solution.

Share Improve this question edited Apr 12, 2018 at 15:29 marquesm91 asked Apr 12, 2018 at 12:41 marquesm91marquesm91 5557 silver badges24 bronze badges 6
  • It might be helpful to know which make/model of TV you're trying to run it on. – Joe Clay Commented Apr 12, 2018 at 13:31
  • @JoeClay updated. I have forgot to provided these infos. – marquesm91 Commented Apr 12, 2018 at 13:46
  • Probably download older desired Chrome version: oldapps./google_chrome.php and work on that in local and see if its successful. Remember its not React running in browser rather JS running in the browser. – Rikin Commented Apr 12, 2018 at 13:53
  • @Rikin yes, you are right. JS running in the browser :) – marquesm91 Commented Apr 12, 2018 at 14:00
  • 1 Thanks, man, saved my day! – kenshinji Commented Feb 22, 2019 at 8:13
 |  Show 1 more ment

2 Answers 2

Reset to default 5

Newer versions of React (v16+) require:

  • The Map and Set data structures
  • The window.requestAnimationFrame() API

According to MDN, basic Map and Set support weren't added to Chrome until version 38, and you had to use a vendor prefix to access requestAnimationFrame until Chrome 24.

Since your TV uses Chrome 23, you'll need to polyfill those APIs. The React docs suggest using core-js or babel-polyfill for this purpose.

If your desired aim is to have your app run just on a smart TV perhaps give react-tv a look: https://github./raphamorim/react-tv

发布评论

评论列表(0)

  1. 暂无评论