An open API service indexing awesome lists of open source software.

https://github.com/mathdroid/react-vr-with-awareness

👀 HOC for creating aware components in ReactVR
https://github.com/mathdroid/react-vr-with-awareness

hoc react react-vr vr

Last synced: 9 months ago
JSON representation

👀 HOC for creating aware components in ReactVR

Awesome Lists containing this project

README

          

# react-vr-with-awareness
👀 HOC for creating aware components in ReactVR

## Usage

```js
import React from "react";
import { AppRegistry, Text, View } from "react-vr";

// import
const Aware, {withAwareness} = require("react-vr-with-awareness");

// create a component with HOC
const AwareFromHOC = withAwareness(beingLookedAt => (

{beingLookedAt ? "Hi there!" : "Look at me!"}

));

// or use the supplied component `Aware` with render props
export default class example extends React.Component {
render() {
return (

{/* Aware component from HOC */}


{/* Aware component with render props */}
(

{seen ? "seen" : "not seen"}

)}/>

);
}
}

AppRegistry.registerComponent("example", () => example);
```

## Docs

`Aware` component takes a `render` props which is a function with 1 `boolean` parameter which indicates if the component is being seen or not. The function should return a react component. This function is similar from the one used in the HOC.

## License

MIT. See [LICENSE](./LICENSE)