question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do I import NativeMethodsMixin?

See original GitHub issue

I did import {NativeMethodsMixin} from 'react-native' but it is undefined. here is exponent example. You will get redbox. https://snack.expo.io/HJq_dCGTl

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
evollucommented, Apr 6, 2017

I think this kind of import only work inside react native project (powered by haste?) For the application everything should come from react-native module. tried your suggestion and failed: https://snack.expo.io/SynGpBXax @hramos

0reactions
johnwatsondevcommented, Aug 28, 2017

@evollu I have a tricky approach. We just use several methods of the object of NativeMethodsMixin.

const NativeMethodsMixin = {
  measure: function(callback) {
    UIManager.measure(findNumericNodeHandle(this), mountSafeCallback(this, callback));
  },
  measureInWindow: function(callback) {
    UIManager.measureInWindow(findNumericNodeHandle(this), mountSafeCallback(this, callback));
  },
  measureLayout: function(relativeToNativeNode, onSuccess, onFail) {
    UIManager.measureLayout(findNumericNodeHandle(this), relativeToNativeNode, mountSafeCallback(this, onFail), mountSafeCallback(this, onSuccess));
  },
  setNativeProps: function(nativeProps) {
    injectedSetNativeProps(this, nativeProps);
  },
  focus: function() {
    TextInputState.focusTextInput(findNumericNodeHandle(this));
  },
  blur: function() {
    TextInputState.blurTextInput(findNumericNodeHandle(this));
  }
};

I copy the dependency of NativeMethodsMixin to a single file.

nativemethodsmixin

So, I can use it anywhere.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unknown named module: 'react/lib/NativeMethodsMixin'
If you change this: import NativeMethodsMixin from 'react/lib/NativeMethodsMixin'; to this: import NativeMethodsMixin from 'react'; your app ...
Read more >
NativeMethodsMixin – React Native - Deco IDE
NativeMethodsMixin provides methods to access the underlying native component directly. This can be useful in cases when you want to focus a view...
Read more >
Direct Manipulation - React Native
... look at the implementation of setNativeProps in NativeMethodsMixin you ... import React from "react"; import { Text, TouchableOpacity, ...
Read more >
Javascript – React Native – How to measure size of content in ...
I want to measure the size of the content in my ScrollView . Therefore, I am using measure from NativeMethodsMixin : import NativeMethodsMixin...
Read more >
import nativemethodsmixin from "nativemethodsmixin"; error - Code ...
import nativemethodsmixin from "nativemethodsmixin"; error. Add Answer | View In TPC Matrix. Technical Problem Cluster First Answered On June 10, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found