I have built a very simple react-native redux app with redux-thunk. When i run my app, i run into the error 'actionTypes is undefined'. Error and the line where the error is.
The app isnt anything to big, just has one action creator file and one reducer file with another index file. Been stuck on this for a couple of day. Anyone that can help, itll be greatly appreciated. Thank you!
Are you exporting from actionTypes.js? Every single type you define there would need to be exported separately.
But do not use the 'default' keyword like you do in your reducer. That's used in the case that you have one thing to export.
I assume you are storing all of your action related const variables in actionTypes.js.
When defining them, you need to export them from the file itself, in order to use them from within another file. I think the code you've provided is fine, but my guess is you are not exporting FETCH_DATA in this case. EG - in actionTypes.js
export const FETCH_DATA = "FETCH_DATA";
...
... // other variables can be done the same way
and so on.
Related
Hello Support I can't get the String from a Component. I did this with 2 ways with bad results.
TextComponent textComponent = (TextComponent) item.displayname;
return textComponent.content();
The result of this is a error with Casting
and
return PlainTextComponentSerializer.plainText().serialize(item.displayname);
The result of this is Literaly "chat.square_brackets" which is weird.
Please Help. Thanks
I also was having trouble with this. Here's what I found to work for me. Full disclosure that I'm developing my plugin on the PaperMC 1.16 fork and not Spigot. So it's possible that this may not work for you, either because it isn't a part of Spigot or because you are working in a version that this feature is not a part of.
To start, I would first check to make sure that we are both on the same page. For me, the component objects being used are from a package called net.kyori.adventure.text if yours are not provided by this package I don't know that this solution will work for you.
Also as mentioned by others, accessing the displayName directly on the ItemStack isn't going to give the desired results. Instead, you need to do itemStack.getItemMeta().displayName(). This method should then return a net.kyori.adventure.text.Component; once you have the component you need to serialize it using one of the serializers from the previously mentioned package.
That will look something like this:
Component itemDisplayName = itemStack.getItemMeta().displayName()
PlainComponentSerializer plainSerializer = PlainComponentSerializer.plain();
String itemName = plainSerializer.serialize(itemDisplayName);
The package that the serializer is from is: net.kyori.adventure.text.serializer.plain.PlainComponentSerializer
I don't understand how you can access to the displayname field in ItemStack in the Spigot API.
You should use ItemMeta to manage display name. To get the item meta, you should use ItemStack#getItemMeta.
Don't forget to check if the item as a meta with hasItemMeta. You can also use hasDisplayName to be sure that the display name is valid.
Is it a good idea to use function name property instead of constants for actions/mutations, like the code below?
Author of Vuex official documentation says that it is not required to use constants for actions/mutations. So I want to try to use type is based on function name.
Component:
this.$store.dispatch(authActions.login.name, {
email: this.email,
password: this.password
})
Action:
async login(context, { email, password }) {
// some code
}
I am waiting for the following answers:
1) Yes, you can use it, there are no potential problems with this
approach.
2) Yes, but these problems [problems] can happen.
3) No, there are a lot of problems: [problems].
I think it's option number 2).
The problem comes when you want to dispatch namespaced modules actions.
You can do this and it does work, but I noticed when I minify my code for production it stops working.
I suspect there's some code that maps the function names (ie login()) to their minified version (ie h()) during bundling, and that's breaking things.
I've been trying to figure this out for a while with no luck. I agree defining constants to use as function names, instead of grabbing the name after like myFunction.name, is stupid. I'll update my comment if I figure it out. I'll keep trying...
I want to access context variable to use the isMobile flag to select a different endpoint depending on the result. I could pass it on the dispatch from the component, but I know there should be one way to do it.
export const actions = {
...
signUpGoogle({ commit }) {
fireauth.useDeviceLanguage()
if (context.isMobile) {
fireauth.signInWithPopup(GoogleProvider).then ...
} else {
fireauth.signInWithRedirect(GoogleProvider)
}
}
I saw here that it can be obtained on server init, but I really don't want to rely on this as caching will mess things up
https://nuxtjs.org/guide/vuex-store/#the-nuxtserverinit-action
Thanks for the help
I'm not sure if you're talking about an environment variable here, but below is the answer if it is.
Looking on this GH issue, we can find out that you can use this.app.$config.isMobile (basically referencing env variables aka publicRuntimeConfig values in your nuxt.config.js).
You can do one thing in nuxtServerInit, set this variable in state using the context, and then use state.isMobile to do this type of API Calls. Hopefully, that should solve this.
If it's not very clear, I can edit to give some code examples
I am trying to separate files in an Elm project, as keeping everything in global Model, Messages, etc. would be just a mess.
Here is how I tried it so far:
So, there are some global files, and then Header has its own files. However I keep getting error, when importing Header.View into my global View:
The 1st and 2nd entries in this list are different types of values.
Which kind of makes sense:
The 1st entry has this type:
Html Header.Messages.Msg
But the 2nd is:
Html Msg
So, my question is whether all the messages (from all my modules, like Header) needs to be combined somehow in global Messages.elm? Or there is a better way of doing this?
My advice would be to keep messages and update in 1 file until that feels uncomfortable (for you to decide how many lines of code that means - see Evan's Elm Europe talk for more on the modules flow). When you want to break something out, define a new message in Main
type Msg
= HeaderMsg Header.Msg
| ....
Then use Cmd.map HeaderMsg in your update function and Html.map HeaderMsg in your view function to connect up your sub-components
Is it possible to add to a CustomMboSet in Maximo using scripting? I am writing a custom application using a custom object called TIMESHEET. As part of the application I am writing a (Jython) script that needs to dynamically build up an MboSet (a set of TIMESHEETs). The code retrieves an existing CustomMboSet and attempts to add elements to it. It works when using an out of box MboSet, but when I try to run the same code on a custom MboSet it does not seem to work. No error is thrown, but code below the offending line is not run.
In other words, this works (LABTRANS is an out of box MBO):
myMboSet = mbo.getMboSet("LABTRANS")
newMbo = myMboSet.add()
# Set attributes on newMbo, everything is happy
But this does not (TIMESHEET is a custom MBO):
myMboSet = mbo.getMboSet("TIMESHEET")
newMbo = myMboSet.add()
# Code does not execute after the above line
Anyone have any insight as to why I am seeing this behavior? Does the Maximo scripting framework simply not support the dynamic building up of CustomMboSets? Any help is appreciated. Thanks.
You need to make sure that the relationship exists between the Current MBO and the Custom MBO in the database configuration otherwise it will not work.
Alternatively you can use the following code to create an new mboSet on the fly:
timeSheetMboSet = mxServer.getMboSet("TIMESHEET", userInfo)
mbo.getMboSet(RELATIONSHIPNAME).
LABTRANS and TIMESHEET must be the relationship names to the object in auto script.
If you want to get/add records in any object, use
mxServer.getMboSet(OBJECTNAME, userInfo)
A bit more explanation. You can create your own custom relationship from within your automation script. The trick is to make sure it's not already existing. That's why I use a dollar sign for mine.
variable = mbo.getMboSet(tempRelationshipName,Object,where clause)
previousPhaseSet = mbo.getMboSet("$wophasetranstemp1", "exitdate is null")