# 暗黑图片动态值

DynamicValue 配合 useDynamicValue 获取动态值

# Class 组件用法

import React from 'react';
import { Image, TouchableOpacity } from 'react-native';
import { injectTheme, DynamicValue } from '@ezviz/rntheme'
 
class DeviceButton extends Component {
  constructor() {
    super();
  }
 
  render() {
    const btnUri = new DynamicValue(require('./dark_btn.png'), require('./light_btn.png'));
 
    return (
      <TouchableOpacity style={styles.button}>
        <Image source={this.props.rntheme.useDynamicValue(btnUri)}/>
      </TouchableOpacity>
    );
  }
}
 
export default injectTheme(DeviceButton);

# Function 组件用法

import React from 'react';
import { Image, TouchableOpacity } from 'react-native';
import { DynamicValue, useDynamicValue } from '@ezviz/rntheme'
 
export default props => {
  const btnUri = new DynamicValue(require('./dark_btn.png'), require('./light_btn.png'));
 
  return (
    <TouchableOpacity>
      <Image source={useDynamicValue(btnUri)}/>
    </TouchableOpacity>
  );
}