Fork me on GitHub
#fulcro
<
2020-12-08
>
Aleksander Rendtslev01:12:03

Hi! I’ve been experimenting with and investigating multiple options for building a fullstack clojure/clojurescript app with RN as the main client app. Fulcro seems perfect for what I’m trying to build, and I’m really stoked about everything that’s been built out here and all the documentation. I am, however, planning on bypassing expo. Does anyone have any pointers on how to set that up with Fulcro?

tony.kay01:12:08

@aleksander990 ummmm…let me see, I’ve got a bare RN app sitting around somewhere…

tony.kay01:12:53

I think I followed the instructions for a bare react native app here: https://docs.expo.io/bare/exploring-bare-workflow/ But you don’t have to use the expo APIs (though I still find them convenient).

tony.kay01:12:51

did the normal MainActivity stuff (return the name of the js module name)

tony.kay01:12:18

nothing special in shadow, other than using the right target type

Aleksander Rendtslev01:12:36

Unrelated to Fulcro: How much overhead does expo bare add vs react native CLI? (I was looking through the code here and trying to reverse engineer it for native native. https://github.com/fulcrologic/fulcro-native/blob/develop/src/main/com/fulcrologic/fulcro_native/bare.cljc). I’m a little worried about app size with expo, but from what I’m gathering it might not be too different than react native cli with bare

tony.kay01:12:40

:app   {:target     :react-native
          :init-fn    app/init

tony.kay01:12:04

you can choose what you add API-wise

Aleksander Rendtslev01:12:13

I got all that setup. The build is compiling and working as expected. I’m just trying to figure out the render-root part

tony.kay01:12:19

so I don’t think expo has to add anything

tony.kay01:12:23

oh, ok, so…

Aleksander Rendtslev01:12:28

(all the sample projects you’ve setup are immensely helpful)

👍 3
tony.kay01:12:04

I’m using `

:optimized-render!      kr2/render!

Aleksander Rendtslev01:12:32

what does this do? (i saw it but couldn’t quite figure out what it’s addding)

tony.kay01:12:23

so you can plug in which algorithm is used to “refresh” after a transaction. This one normally renders from root, but supports you passing a targeted ident via transact! to limit refresh to some specific component, which can be used to speed up large forms.

tony.kay01:12:48

multi-root-render is just like KF2, but allows you to have disconnected nested data roots in the app.

tony.kay01:12:06

ident-optimized-render tries to only update components whose data changes by analyzing the normalized database…but it turned out to be no faster in most cases, and is more complex to use.

tony.kay01:12:40

don’t honestly remember what the default is right now 😜

Aleksander Rendtslev01:12:14

ha ha, that’s fair. I’m thoroughly impressed with everything you’ve pioneered here. And your responsiveness on this. I appreciate knowing the “why”, so this makes me a lot more comfortable jumping in

tony.kay02:12:41

yep, I’m the same way. Don’t like mysteries.

tony.kay01:12:08

keyframe render 2

tony.kay01:12:25

:render-root!      bare/render-root!

tony.kay01:12:43

(from fulcro-native.bare)

tony.kay01:12:12

then (app/mount! app root/Root :i-got-no-dom-node)

tony.kay01:12:53

I think that’s it

tony.kay01:12:35

Oh I see, I’m using expo’s registerRootComponent

tony.kay01:12:32

I’d just look in the js and see what that does…it just adds a bit of expo magic in, but it stil lhas to call the RN low-level calls

tony.kay01:12:11

import 'expo/build/Expo.fx';
import { AppRegistry } from 'react-native';
export default function registerRootComponent(component) {
    AppRegistry.registerComponent('main', () => component);
}

tony.kay01:12:25

doesn’t look like it does much at all 😜

tony.kay01:12:00

so you should just be able to registerComponent yourself

Aleksander Rendtslev01:12:38

ha ha, ok so I suppose that that, an asset management is the only thing that’s expo specific

Aleksander Rendtslev02:12:34

Out of curiosity: Do you remember the approximate app size of your RN apps? It looks like the base bundle is quite a bit bigger than the the reagent build I got running (1.2mb vs 5.2mb when building for release). My guess is that it’s because Fulcro includes a lot else, but my app right now is nothing more than a view with text in it

Aleksander Rendtslev03:12:14

Ok, changing for this is all it took: (.registerComponent rn/AppRegistry “main” (fn [] Root))

Aleksander Rendtslev03:12:54

Ok, a few notes: • I’d be happy to do a PR with a native.cljc for use cases without expo. It’s a simple change, but that’ll make it easy for anyone to get started • The alpha UI components imports a few components that have been moved outside core RN library (it throws a couple of warnings. So they should be removed • Preassigning all the basic ui-components seem to make them part of the bundle - regardless of whether you use them. (they won’t be treeshaken). I don’t know if that has to do with how (comp/isoget) is implemented or something else. Easy solution is to simply not do it and leave it up to the user. Meaning I’ll only do the import for the components I actually need. And then have the components ns expose the react-factory helper function Let me know if you have any thoughts on it. Otherwise I’ll experiment some more tomorrow and submit some PRs to the repo

tony.kay23:12:05

(1) sure, adding a new ns for that is fine (2) Sounds like removing them is the right thing to do. (3) If you don’t require it, nothing should end up in your build. If it is required where not needed, I’m open to a fix.

Aleksander Rendtslev02:12:11

I did a low quality test for number 3: I build a production build with them and one without them and it resulted in a 200kb difference. I can try to look through the actual index file and document in a PR

Adam Helins12:12:37

For a very specific use case, is it allowed to access a component's parent via this (ie. (.-fulcro$parent (.-props this))) ? Or is it definitely not part of the public API?

tony.kay15:12:25

see comp/get-parent

tony.kay16:12:24

the internal keys are unlikely to change names, but I make no guarantees about the internals of how components are implemented

Adam Helins16:12:38

@tony.kay Thanks, perfect. It seems to be a somewhat recent change as it was not part of the API version I was accessing on Cljdoc. Recent versions are faulty, namespaces don't show up. I tried rebuilding it but it fails.

Jakub Holý (HolyJak)18:12:23

I am working on getting latest Fulcro to Cljdoc

👏 3
🙌 3
Adam Helins18:12:26

@U0522TWDA Thanks, that would certainly be useful

💯 3
tony.kay23:12:21

Yeah. It was in F2, and I forgot to bring it forward until recently. Evidently not used much 😜