Hi ! Hoàng đang có 2 class render A và B viết bằng ReactJS. Hoàng phải làm sao để màn hình PC 1200px thì class A sẽ được hiển thị ra trình duyệt còn nếu trên mobile 700px thì class B sẽ được render.
Cảm ơn cả nhà đã giúp đỡ Hoàng 🙆
file A.js
import React, { Component } from 'react';
class A extends Component {
}
render() {
return (
<div>
Đây là component
dành cho PC
</div>
);
}
}
export default A;
file B.js
import React, { Component } from 'react';
class B extends Component {
}
render() {
return (
<h1>
Đây là component
dành cho mobile
</h1>
);
}
}
export default B;
file index.js
import React from 'react';
import ReactDOM from 'react-dom';
import A from './A.js';
import B from './B.js';
ReactDOM.render(
<A />
<B /> ,
document.getElementById('root')
);
file index.html
<html>
<head>
</head>
<body>
<div id="root"></div>
</body>
</html>