Skip to content
This repository was archived by the owner on Apr 26, 2025. It is now read-only.

[draft] navigation as HOC #100

Closed
wants to merge 17 commits into from
Closed

[draft] navigation as HOC #100

wants to merge 17 commits into from

Conversation

raphamorim
Copy link
Owner

@raphamorim raphamorim commented Dec 19, 2017

Working in Progress [Draft]

Ref: #85

import React from 'react'
import ReactTV, { withFocusable, withNavigation } from 'react-tv'

const Item = ({focused, setFocus, focusKey}) => {
  focused = (focused) ? 'focused' : 'unfocused'
  return (
    <div className={focused} onClick={() => setFocus()}>
      It's {focused} Item
    </div>
  )
}

const FocusableItem1 = withFocusable(Item, {focusKey: 'focusKey-1'})
const FocusableItem2 = withFocusable(Item, {focusKey: 'focusKey-2'})
const FocusableItem3 = withFocusable(Item, {focusKey: 'focusKey-3'})

function App(props) {
  return (
    <div>
      <h1>Current FocusKey: "{props.currentFocusKey}"</h1>
      <FocusableItem1/>
      <FocusableItem2/>
      <FocusableItem3/>
    </div>
  )
}

export default withNavigation(App)

@raphamorim raphamorim mentioned this pull request Jan 15, 2018
@raphamorim
Copy link
Owner Author

Closing it in favour of a separated package: https://github.com/react-tv/react-tv-navigation
However still have to remove navigation from renderer

@raphamorim raphamorim closed this Jan 16, 2018
@raphamorim raphamorim deleted the navigation branch January 16, 2018 13:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants