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
- Host: GitHub
- URL: https://github.com/mathdroid/react-vr-with-awareness
- Owner: mathdroid
- License: mit
- Created: 2017-04-20T05:53:55.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-13T23:22:25.000Z (over 8 years ago)
- Last Synced: 2025-05-05T00:52:44.231Z (9 months ago)
- Topics: hoc, react, react-vr, vr
- Language: JavaScript
- Homepage:
- Size: 3.19 MB
- Stars: 13
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)