Fork me on GitHub
#cljsrn
<
2019-05-27
>
manu11:05:45

Hi! How do you require functions on cljs? for example I have (from NativeBase https://docs.nativebase.io/Customize.html#theaming-nb-headref)

import React, { Component } from 'react';
import { Container, Content, Text, StyleProvider } from 'native-base';
import getTheme from './native-base-theme/components';
import material from './native-base-theme/variables/material';
export default class ThemeExample extends Component {
  render() {
    return (
      <StyleProvider style={getTheme(material)}>
        <Container>
          <Content>
            <Text>
              I have changed the text color.
            </Text>
          </Content>
        </Container>
      </StyleProvider>
    );
  }
} 
I've installed './native-base-theme/components'; in my project, but I don't know how to require getTheme. Someone can explain me how to correctly require not-component things? thx

manu15:05:45

yeah it works for components.. but getTheme is not a component

manu15:05:07

if you see it's not into {}

dotemacs16:05:37

In your project, run: yarn add native-base. Then in your code, do something like:

(def native-base (js/require "native-base"))
(def get-theme (r/adapt-react-class (.-getTheme native-base))) 
...

manu17:05:21

i cannot do this because getTheme is not a property.. It's the default exported from the library

dotemacs17:05:17

(def native-base (js/require "native-base"))
(def get-theme (-> native-base
                   (goog.object/get #js ["getTheme"])
                   r/adapt-react-class))

dotemacs20:05:41

OK, sorry, my bad. Try this: after installing native-base you have to: node node_modules/native-base/ejectTheme.js then run: re-natal require ./native-base-theme/components followed by: re-natal use-figwheel then at the REPL: (def get-theme (aget (js/require "./native-base-theme/components") "default")) or better: (def get-theme (goog.object/get (js/require "./native-base-theme/components") #js ["default"]))

dotemacs20:05:25

(watch out for those double quotes, Slack messes them up)

manu07:05:16

Yeah this was exactly what I meant.. and I've already tried your solution but It doesn't work..