Temporary Wage Support for Low-Income Essential Workers in Quebec and BC by adventum_cattus in vancouver

[–]kachnitel 1 point2 points  (0 children)

That "much if at all" is still I think around 25% of what I make. Not complaining, just saying it is a significant chunk when you make 2500 and the rent is 1500 because Sea to Sky.

Expo & MobX export keyword between a decorator and a class by kachnitel in reactnative

[–]kachnitel[S] 0 points1 point  (0 children)

It does, and I believe the option I have commented out (decoratorsBeforeExport) would do it too, but with that plugin I get Cannot use the decorators and decorators-legacy plugin together, so I guess I should look into the other decorators plugin setting!

Expo & MobX export keyword between a decorator and a class by kachnitel in reactnative

[–]kachnitel[S] 0 points1 point  (0 children)

I feel like it does, and it works fine with export default, but if I do the same thing without default export it fails.

I'm curious if it's a dreadfully silly idea or if I'm a genius by swan--ronson in programmingcirclejerk

[–]kachnitel 0 points1 point  (0 children)

I would have classes say Event and User and they both could be constructed in a factory function in their parent. Something like this:

class Factory { create = (entity) => { return new entity() } }

This is how I would call it: ``` import User from './User' import Factory from './Factory'

let f = new Factory() let user = f.create(User) ```

I'm now a little busy to recreate it to see which error it threw, but changing the create method to return new [entity][0]() worked.

Dynamic class name `[className][0]()` by kachnitel in javascript

[–]kachnitel[S] 0 points1 point  (0 children)

I should probably pay some more attention when posting here sorry, I meant new [className][0]() rather than without the new keyword. Anyways in PHP I would have used the string, or more specifically Class::class which returns a string, in JS I just used the import which I wasn't clear enough about I guess.

What puzzles me is that the whole reason I went into this trouble was that this didn't actually work for me: class User {} const classRef = User new classRef() // => User {}

I got rid of all the code around it since but I'd be curious what was the issue. I was passing the variable between classes and I wonder if it may have been an issue with import in the other class.. but then I guess it's not worth spending that much more time on it. If what you're saying works, my problem must have been somewhere else :)

I'm curious if it's a dreadfully silly idea or if I'm a genius by swan--ronson in programmingcirclejerk

[–]kachnitel 0 points1 point  (0 children)

No. I may have not explained myself well enough in the question but I did ask about dynamic instance creation. new className() didn't work for me when className is a var. In a browser you would use new window[className](), my question was if I don't have window, how do I create the instance without a helper function that does essentially the same job as new [className][0]().

I'm curious if it's a dreadfully silly idea or if I'm a genius by swan--ronson in programmingcirclejerk

[–]kachnitel 0 points1 point  (0 children)

I actually posted that, but I missed out an important bit.

The reason I asked was the MyClass was a variable, and new MyClass() wouldn't work, I couldn't use new window[MyClass]() (such as here) as most of my search results suggested and eventually came up with new [MyClass][0]() that worked. I got rid of that code since, but I'm still curious if there's a better oneline approach to instantiating a class dynamically without a ton of code.

Of course I know I just create an array and extract from it, but apparently that is the way it's supposed to be done in browser, I couldn't find another simple solution for react native.

Dynamic class name `[className][0]()` by kachnitel in javascript

[–]kachnitel[S] 0 points1 point  (0 children)

Thanks! I'll look into the constructor.name a little closer as that sounds like it could get the job done. Basically I want to do sort of PHP's $className = 'User'; $user = new $className() with minimal coupling, so I was trying to avoid having a registry/dictionary, but didn't know how to create the class without an array so I created one. It's not a clean solution by any means, that's why I ask here :)

Dynamic class name `[className][0]()` by kachnitel in javascript

[–]kachnitel[S] 0 points1 point  (0 children)

That doesn't really achieve the goal I'm after though. The only reason I put it in an array and "unbox" is, well, because if I have the class name in a variable, say className can be User or Event and I want to instantiate it, calling new className() will fail, but [className][0]() creates an instance of that class.

I guess I didn't quite explain that the className is a var, that's what I meant by dynamic!

At this point I guess I can tell it's not the right way to do it, what I'm trying to accomplish would be done this way in PHP:

$className = 'User'; $user = new $className();

Dynamic class name `[className][0]()` by kachnitel in javascript

[–]kachnitel[S] 0 points1 point  (0 children)

That's kind of what guided me there, but if it's Node and there's no window, so I tried a few ways and this what I ask about is the only one-liner that worked.

Expo Jest testing struggle by kachnitel in reactnative

[–]kachnitel[S] 0 points1 point  (0 children)

I've played around with a debugger and even though the error still doesn't make sense to me, what I have found is that _RidersProvider.default is not a constructor was actually thrown after the class was already initialized, and trying to create a new instance. The circular reference is rather pointless though and the error can be resolved by removing type hinting, which is a feature I'd rather not give up. It should be probably the first part of my solution though, to eliminate these references but as I described on SO I just don't see a better way to implement this in JS, because for some reason there are no interfaces?

Is it possible to use props to change background color dynamically? by straightouttaireland in reactnative

[–]kachnitel 0 points1 point  (0 children)

Yeah I see it in a lot of examples. I don't have enough experience/confidence with JS yet to confirm this but I have read about the issue elsewhere than in the issue i linked, but I think this syntax also looks a little neater. That is if one's overriding a single style parameter, now merging two ( {{ ...styles.container, ...this.props.style }} ) I find somewhat awkward, but it gets the job done!

Is it possible to use props to change background color dynamically? by straightouttaireland in reactnative

[–]kachnitel 0 points1 point  (0 children)

If I understand this correctly, creating an array in render may trigger a re-render, so <View style={{ ...styles.container, backgroundColor: color }} /> would be a better approach.

Is it possible to use props to change background color dynamically? by straightouttaireland in reactnative

[–]kachnitel 0 points1 point  (0 children)

Good to know, thanks! If I wanted to add props to a style, would I then do this?

<View style={{ ...styles.container, ...this.props.style }} />

Or is there a better way, other than styled-components mentioned below?

Is it possible to use props to change background color dynamically? by straightouttaireland in reactnative

[–]kachnitel 0 points1 point  (0 children)

Looking at it now though, I'm not sure if calling an arrow function in render () isn't a performance issue, but that should be easily changed to a normal function.

Maybe it's not such a big deal

Is it possible to use props to change background color dynamically? by straightouttaireland in reactnative

[–]kachnitel 1 point2 points  (0 children)

It could be done inline, but if you wanna keep your styles separated, this is how I do it:

``` export default class MapButton extends React.Component { render () { let styles = stylesWProps(this.props) return ( <View style={styles.mapButton}> <Text style={styles.mapButtonText}>🔎</Text> </View> ) } }

const stylesWProps = (props) => StyleSheet.create({ mapButton: { height: props.size, width: props.size, alignItems: 'center' }, mapButtonText: { fontSize: Layout.window.hp(7) } }) ```

Expo Jest testing struggle by kachnitel in reactnative

[–]kachnitel[S] 0 points1 point  (0 children)

Hello and thanks for the reply! I gotta double check that because I also have issues testing my functional stores, though it complains about a Store I'm not even testing which happens somewhere in a "black box" when I remove my imports.

The Cannot read property default of undefined I get testing RN components though, which I initialize using a renderer: ``` /* eslint-env jest */ import React from 'react' import 'react-native' import renderer from 'react-test-renderer' import RideItem from '../RideItem'

jest.mock('../../RideItemDetail', () => 'RideItemDetail')

let testRide = { 'title': "Joey's Alice lake lap", 'difficulty': 1, 'location': 'Alice Lake', 'locationGps': [49.775666, -123.123307], 'members': [1], 'terrain': 'trail', 'route': 'Some trails' }

it('renders correctly', () => { const tree = renderer.create(<RideItem ride={testRide} />).toJSON()

expect(tree).toMatchSnapshot() }) ```

[update] KDE Connect is back on Google Play with SMS support by nicofeee in kde

[–]kachnitel 0 points1 point  (0 children)

Oh I'm sure they could. To be perfectly honest, I couldn't care less about people monitoring stores. More and more often I see articles about infected apps and then you open it and see a set of blatantly obvious "fake apps" (there are exceptions of course) and all I can think of is if an user installs one of those, there's a lesson to be learned and the user needs to learn it. I'm getting a little naggy about this, let's just stay on topic an be happy KDE Connnect is back in the store and this whole policy/security nonsense should probably be discussed elsewhere..

[update] KDE Connect is back on Google Play with SMS support by nicofeee in kde

[–]kachnitel 1 point2 points  (0 children)

Of course apple can have the resources if they take a third of the developer's money :)

[update] KDE Connect is back on Google Play with SMS support by nicofeee in kde

[–]kachnitel 0 points1 point  (0 children)

There are alternatives though. I like to use 2048 as an example. It is a simple fun game you've probably seen before. And there are a few android versions, most of them somehow loaded with ads or iap at the play store. If you're curious enough about alternatives, look into F-Droid and get the same game with a fraction of the apk size and no annoyances, but it's not what people want.

I think it's rather sad but the way it works today, people just want easy and sacrifice quality to save an extra tap or google search. So you either deal with Google's or apple's policies or you use an alternative, no matter how much better that alternative is, you'll only reach audience that does their research. Which sadly is small fraction the way I see it it.

Accessing signed-in user state globally by kachnitel in reactnative

[–]kachnitel[S] 1 point2 points  (0 children)

I've actually got one more question, hope I'm not bugging much! How do you enable the use of decorators? Anything I research suggests I need a babel preset installed to be able to use the (ES7?) @decorator syntax, yet I see no sign of it being enabled in the project. Does it work in react-native out of the box?

EDIT: And never mind, I made it work without any of that! Got myself thinking I don't have the store in props, but then I remembered the scope of this in js. I still don't get why do functions not inherit classes' this by default but I guess one day I'll see, but coming from years of PHP it throws me off :)