| import React from 'react'; | |
| class Counter extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { counter: 0 }; | |
| this.increment = this.increment.bind(this); | |
| } | |
| increment() { |
Основная задача тестового не узнать как сильно вы знаете React, а посмотреть насколько хорошо вы сможете разобраться с новыми технологиями в относительно короткий срок. В идеале, на него нужно потратить не более 3 дней. А так - делайте сколько делается, пока мы не закроем вакансию ;)
Нужно написать одностраничное приложения для просмотра фильмов с помощью The Movie Database API.
При открытии приложения, должен отображаться список популярных фильмов с пагинацией или динамической подгрузкой (на выбор). Также на странице должно быть поле для поиска. Когда ты вводишь туда какой-то текст, должны отобразиться фильмы которые ему соответствуют. Для каждого фильма в списке должен отображаться список жанров (названий жанров, не айдишек), к которым он принадлежит.
| |
| // connect() is a function that injects Redux-related props into your component. | |
| // You can inject data and callbacks that change that data by dispatching actions. | |
| function connect(mapStateToProps, mapDispatchToProps) { | |
| // It lets us inject component as the last step so people can use it as a decorator. | |
| // Generally you don't need to worry about it. | |
| return function (WrappedComponent) { | |
| // It returns a component | |
| return class extends React.Component { | |
| render() { | |
| return ( |
| /* Sometimes it's pretty easy to run ito troubles with React ES6 components. | |
| Consider the following code: */ | |
| class EventStub extends Component { | |
| componentDidMount() { | |
| window.addEventListener('resize', this.onResize.bind(this)); //notice .bind | |
| } | |
| componentWillUnmount() { | |
| window.removeEventListener('resize', this.onResize.bind(this)); |
| // sending to sender-client only | |
| socket.emit('message', "this is a test"); | |
| // sending to all clients, include sender | |
| io.emit('message', "this is a test"); | |
| // sending to all clients except sender | |
| socket.broadcast.emit('message', "this is a test"); | |
| // sending to all clients in 'game' room(channel) except sender |
| /* HOC fundamentally is just a function that accepts a Component and returns a Component: | |
| (component) => {return componentOnSteroids; } or just component => componentOnSteroids; | |
| Let's assume we want to wrap our components in another component that is used for debugging purposes, | |
| it just wraps them in a DIV with "debug class on it". | |
| Below ComponentToDebug is a React component. | |
| */ | |
| //HOC using Class | |
| //it's a function that accepts ComponentToDebug and implicitly returns a Class | |
| let DebugComponent = ComponentToDebug => class extends Component { |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="background.js"></script> | |
| </head> | |
| <body> | |
| <textarea id="sandbox"></textarea> | |
| </body> |
This has been incorporated in a small library.