Fork me on GitHub
#cljsrn
<
2017-10-12
>
gonbe7708:10:23

I'm finding problems after running re-natal init <string> for certain strings. The project directory is generated, but at runtime, the packager complains of a conflict. For example, using "Modal" as in "re-natal init Modal". Multiple strings lead to this difficulty -- from a freshly generated re-natal project directory, cd-ing to node_modules/react-native/Libraries and running the following gives some more examples: find | grep js$ | xargs -n1 basename -s .js | sort # does anyone else see this?

pesterhazy08:10:38

@gonbe77 I guess the package names needs to be unique?

pesterhazy08:10:49

i.e. the name set in package.json

pesterhazy08:10:01

don't pick a name that exists in npm?

gonbe7708:10:31

but in general, there is no way to predict what names will end up in that directory in the future, right?

pesterhazy08:10:04

true but isn't that a problem shared by react-native init, create-react-app etc.?

pesterhazy08:10:18

blame npm, I say

gonbe7708:10:02

lol -- well, that isn't going to address this instance of one of the two hard problems of comp sci...

pesterhazy08:10:11

which one - cache invalidation or off by one errors?

gonbe7708:10:30

ha ha ha -- i thought one of the two was 'naming'

gonbe7708:10:16

the background of this is that i've been making a collection of simple re-natal demos -- when i use CamelCase as suggested in the README.md i tend to run into this more, whereas using all lower-case seems to be somewhat safer

pesterhazy08:10:05

I guess it depends on the name that ends up in package.json? Can you name a few broken/non-broken examples

gonbe7709:10:50

i just tested: utf8 (has conflict), YellowBox (has conflict), utf9 (no conflict)

gonbe7709:10:30

yes, i think the name in package.json is relevant

vikeri09:10:01

Maybe add a check against the npm registry in re-natal before scaffolding the project (making sure the name is unique)

gonbe7709:10:41

that is helpful for now, but if there are updates to react native, and new names are added, will this not be a problem for some existing projects?

pesterhazy09:10:29

well I guess not calling your project utf8 is just common sense šŸ™‚

pesterhazy09:10:57

does npm complain about a dupe?

gonbe7709:10:08

sorry if i wasn't clear, i see a message after react-native start -- Loading dependency graph...jest-haste-map: @providesModule naming collision: Duplicate module name: utf8 Paths: ... utf8/package.json collides with ... utf8.js This warning is caused by a @providesModule declaration with the same name across two different files.

gonbe7709:10:45

i did not understand what you meant about npm complaining about a dupe.

pesterhazy09:10:33

yeah that's what I meant

gonbe7709:10:13

i guess as there are only 385 relevant strings at the moment, it's not likely to be a significant problem šŸ™‚

sachinharpalani11:10:10

Hi, im currently using cljs for react-native app and having some issue in the interop of HighOrderComponent. The library i want to use is : https://github.com/okgrow/react-native-joyride My code:

(def JoyRide (js/require "react-native-joyride"))
(def Joy (.joyride JoyRide))
(def JoyrideStep  (r/adapt-react-class (.-name (.-JoyrideStep JoyRide))))
(def JoyrideText  (r/adapt-react-class (.-name (.joyridable JoyRide (r/reactify-component (clj->js (.-Text ReactNative)))))))

(defn joyride-page []
  (.log js/console JoyrideStep JoyrideText)
  [JoyrideStep (clj->js {:text  "Hey! This is the first step of the tour!"
                         :order 1
                         :name "openApp"})
   [JoyrideText "Welcome to the demo of joyride library"]])

(defn m-joyride-page []
  (let [m (-> joyride-page
              r/reactify-component
              Joy
              r/adapt-react-class)]
    [m]))
I am getting the following error :
[Invariant Violation: Expected a component class, got [object Object].]
and my log is
{
  "class": null,
  "id": null,
  "name": "JoyrideStep",
}  {
  "class": null,
  "id": null,
  "name": "",
}
Any help would be appreciated šŸ™‚

pesterhazy11:10:08

@sachinharpalani how would you use that component in JS?

sachinharpalani11:10:56

@pesterhazy sorry i didnt get you?

pesterhazy11:10:30

suppose you wrote this in JS, how would you use Joy?

sachinharpalani11:10:58

@pesterhazy im using cljs (expo+re-frame)

sachinharpalani11:10:26

@pesterhazy this is the code im refering :

import React from 'react';
import { StyleSheet, Text, Image, View, TouchableOpacity } from 'react-native';
import { Ionicons } from '@expo/vector-icons';

import { joyride, joyridable, JoyrideStep } from 'react-native-joyride';

const JoyrideText = joyridable(Text);
const JoyrideImage = joyridable(Image);

class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <JoyrideStep text="Hey! This is the first step of the tour!" order={1} name="openApp">
          <JoyrideText style={styles.title}>
            Welcome to the demo of
            {'\n'}
            "React Native Joyride"
            </JoyrideText>
        </JoyrideStep>
        <View style={styles.middleView}>
          <JoyrideStep text="Here goes your profile picture!" order={2} name="secondText">
            <JoyrideImage
              source={{ uri: 'https://pbs.twimg.com/profile_images/527584017189982208/l3wwN-l-_400x400.jpeg' }}
              style={styles.profilePhoto}
            />
          </JoyrideStep>
          <TouchableOpacity style={styles.button} onPress={() => this.props.start()}>
            <Text style={styles.buttonText}>START THE TUTORIAL!</Text>
          </TouchableOpacity>
        </View>
        <View style={styles.row}>
          <JoyrideStep text="Here is an item in the corner of the screen." order={3} name="thirdText">
            <JoyrideText style={styles.tabItem}>
              <Ionicons name="ios-contact" size={40} color="#888" />
            </JoyrideText>
          </JoyrideStep>

          <Ionicons style={styles.tabItem} name="ios-game-controller-b" size={40} color="#888" />
          <Ionicons style={styles.tabItem} name="ios-globe" size={40} color="#888" />
          <Ionicons style={styles.tabItem} name="ios-navigate-outline" size={40} color="#888" />
          <Ionicons style={styles.tabItem} name="ios-rainy" size={40} color="#888" />
        </View>
      </View>
    );
  }
}

export default joyride()(App);

sachinharpalani11:10:02

@pesterhazy im sorry im not familiar with js that much

pesterhazy12:10:42

@sachinharpalani there's too much stuff going on to see the problem

pesterhazy12:10:06

can you narrow it down to a minimal example that works in JS? then we can help with the translation to CLJS

sachinharpalani12:10:34

@pesterhazy @sundarj @lovuikeng @binora I solved this with the below changes. Thanks for your help šŸ™‚

(def JoyRide (js/require "react-native-joyride"))
(def Joy (.joyride JoyRide))
(def JoyrideStep  (r/adapt-react-class (.-JoyrideStep JoyRide)))
(def JoyrideText  (r/adapt-react-class (.joyridable JoyRide (clj->js (.-Text ReactNative)))))

(defn joyride-page [props]
  (let [{:keys [start visible]} (js->clj props :keywordize-keys true)]
    [view
     [JoyrideStep {:text  "Hey! This is the first step of the tour!"
                   :order 1
                   :name "first"}
      [JoyrideText "\n\n\n\nWelcome to the demo of joyride library"]]
     [JoyrideStep {:text  "Hey! This is the SECOND step of the tour!"
                   :order 2
                   :name "second"}
      [JoyrideText "\n\n\n\n\nWelcome to the demo of joyride library"]]
     [JoyrideStep {:text  "Hey! This is the tHIRD step of the tour!"
                   :order 3
                   :name "third"}
      [JoyrideText "\n\n\n\n\nWelcome to the demo of joyride library"]]
     [touchable-highlight {:on-press #(start)}
      [text {:style {:text-align "center" :font-weight "bold"}} "START TUTORIAL"]]]))

(defn m-joyride-page []
  (let [m (-> joyride-page
              r/reactify-component
              Joy
              r/adapt-react-class)]
    [m]))

(defn app-root []
[m-joyride-page]) 

pesterhazy12:10:59

@sachinharpalani nice. What's the key change?

lovuikeng12:10:51

sorry but... #cljsrn , "rn" means?

sundarj13:10:30

react native

sachinharpalani13:10:54

@pesterhazy removed (.-name) and (r/reactify-component) while defining JoyrideStep and JoyrideText

borkdude15:10:53

Hi! Iā€™m trying Re-natal and Iā€™m following the README. > npm install -g re-natal > re-natal init FutureApp > cd future-app > react-native run-ios > /dev/null I get zsh: command not found: react-native. Iā€™m not really familiar with all this npm stuff, but does this mean I have to alter the PATH myself?

wojciech15:10:03

Try npm install -g react-native

wojciech15:10:04

It needs to be available globally, for the react-native command to work. Alternatively, you can dig into node_modules to find your local executable, then you'd run something like ./node_modules/react-native/bin/ā€¦ run-ios

borkdude15:10:16

ok, now I get: > Looks like you installed react-native globally, maybe you meant react-native-cli?

borkdude15:10:20

installing react-native-cli globally did the trick

borkdude15:10:58

cool, it works!

wojciech16:10:55

Sorry, I always forget those are separate packages

borkdude16:10:27

Does anyone here has a working example with playing an mp3?

borkdude18:10:49

If I want to run a re-natal app on my iphone, how should I proceed after connecting my iphone and executing: > re-natal use-ios-device real Should I still run: > react-native run-ios ? This opens the simulator again.

joshmiller21:10:21

@borkdude That just sets up figwheel to run on the correct port, to actually run on the real device, either run from XCode (I usually do this) or react-native run-ios --device "Max's iPhone"