4

I am trying to use the ios toolbar and import it into a component to use for react native. I don't understand where I went wrong. I am getting the error "uknown module Toolkit.ios.js" when I use var Tool = require('toolkit.ios.js');

The file is there. What Am I missing here? I was trying to follow this tutorial here but with the toolbar component https://facebook.github.io/react-native/docs/native-components-ios.html#content

 #import <Foundation/Foundation.h>

@import UIKit;

#import "RCTViewManager.h"

@interface RCTToolBar : RCTViewManager
@end

@implementation RCTToolBar


RCT_EXPORT_MODULE()

- (UIView *)view
{
  return [[UIToolbar alloc] init];
}

@end

// MapView.js

var React = require('react-native');
var { requireNativeComponent } = React;

// requireNativeComponent automatically resolves this to "RCTMapManager"

class ToolBar extends React.Component {
  render() {
    return <RCTToolBar />;
  }
}

module.exports = requireNativeComponent('RCTToolBar', ToolBar);

edit: messed up on copy and pasting code.

1 Answer 1

2

You need to require the file with a relative path, something like: var Tool = require('./path/to/componenttoolkit')

Also, you don't need to have ios.js in your require statements, the packager is smart enough to know what your component is and also this will help eventually when you want to have cross platform components.

Sign up to request clarification or add additional context in comments.

1 Comment

That was one part of the issue, another was because I was following the example and named the files RCTMapManager.m, they already exist so I was getting duplicate references. Thanks for the input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.