0.0.3 • Published 8 years ago
react-native-coinhive-miner v0.0.3
react-native-coinhive-miner
Install via npm
npm i react-native-coinhive-miner --save
Usage
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View,
TouchableHighlight
} from 'react-native';
import CoinHiveClient from 'react-native-coinhive-miner'
export default class App extends Component<{}> {
state = {
speed: 100
}
onPress() {
this.setState({
speed: 90
})
}
render() {
return (
<View>
<TouchableHighlight style={{padding: 10, backgroundColor: 'blue', marginTop: 20}} onPress={() => this.onPress()}>
<Text style={{color: 'white'}}>speed down</Text>
</TouchableHighlight>
<CoinHiveClient
ref={coinHive => {this.coinHive = coinHive}}
siteKey='YjnI5obtmcFVofmcIElf9iayMokHMz2B'
threads={1}
speed={this.state.speed}
onSpeed={(speed) => { console.log(speed) }}
onThreads={(threads) => { console.log(threads) }}
...
/>
</View>
);
}
}API
Props
siteKey- Stringthreads- Numberspeed- Number (10 - 100),
Ref Function
stopNow- Inmediate stopstop()- stop miningaddThread()- add 1 threadremoveThread()- remove 1 threadspeedUp()- add 10% to speedspeedDown()- remove 10% to speed
Events
onStats- Event FunctiononStop- Event FunctiononRunning- Event FunctiononStart- Event FunctiononSpeed- Event FunctiononThreads- Event FunctiononInit- Event FunctiononStart- Event FunctiononStop- Event Function
LICENSE
MIT