Failed building JavaScript bundle
Today I installed react-native-material-kit to use on my react-native app. I'm getting an error when I try to create a button.
import React, { Component } from 'react';
import { Text } from 'react-native';
import { MKButton, MKProgress, MKSpinner } from 'react-native-material-kit';
class SearchButton extends Component {
const ColoredRaisedButton = MKButton.coloredButton()
.withText('BUTTON')
.withOnPress(() => {
console.log("Hi, it's a colored button!");
})
.build();
render(){
return (
<ColoredRaisedButton />
);
}
};
export default SearchButton;
I'm running the app using expo.io. When I run the app on my android phone I'm getting an error on my mobile saying
/home/pankaja/Document/Projects/react-native/instaTrending/components/search_button.js: Unexpected token(7:8) at search_button.js:7:8
What's the issue with this ? How to solve this
Hi,
don't use double quotes in react-native - es6 says only single quotes. You should also get yourself a lint checker built into your editor.
The error is probably a misplaced , or apostrophe or something like that. A good lint checker will catch this.
Change up ypur message to log message to simple say colored button - will elimiate all that double / single apostrophe nonsense.
Other than that, check your ) and } and semi-colons. Again, something a lint checker would find.
Good luck,
Cheers, Markus
On 2018-01-14 14:25, Thidasa Pankaja Paranavitharana wrote:
Today I installed react-native-material-kit to use on my react-native app. I'm getting an error when I try to create a button.
|import React, { Component } from 'react'; import { Text } from 'react-native'; import { MKButton, MKProgress, MKSpinner } from 'react-native-material-kit'; class SearchButton extends Component { const ColoredRaisedButton = MKButton.coloredButton() .withText('BUTTON') .withOnPress(() => { console.log("Hi, it's a colored button!"); }) .build(); render(){ return ( <CustomButton /> ); } }; export default SearchButton; |
I'm running the app using expo.io. When I run the app on my android phone I'm getting an error on my mobile saying
/home/pankaja/Document/Projects/react-native/instaTrending/components/search_button.js: Unexpected token(7:8) at search_button.js:7:8What's the issue with this ? How to solve this
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xinthink/react-native-material-kit/issues/379, or mute the thread https://github.com/notifications/unsubscribe-auth/Af6JZcCEc-1x_utdf3ehKuI7ctSY_o8Lks5tKgAsgaJpZM4Rdl7V.
I took that code from the readme . So then readme itself is a error-nous code right? I changed that log code and still the same.
As you use expo and create native React app you can not use this libraire since they don’t let you link native code to your application.
Le 14 janv. 2018 à 19:10, Thidasa Pankaja Paranavitharana [email protected] a écrit :
I took that code from the readme . So then readme itself is a error-nous code right? I changed that log code and still the same.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
@Crash-- So isn't there anyway to use this in create-react-native-app ? If not how can I use this ?
Btw, I thought the issue was because I've declared the ColoredRaisedButton button outside the render method. Isn't it the reason ?
The declaration of your button is certainly the root of this error. But RNMK components requires lot of native code. So pretty soon you’ll start seeing red border for instance.
If you want to use this lib you have to stop using expo or at least waiting the support of third party native component to it.
Le 14 janv. 2018 à 20:10, Thidasa Pankaja Paranavitharana [email protected] a écrit :
@Crash-- So isn't there anyway to use this in create-react-native-app ? If not how can I use this ? Btw, I thought the issue was because I've declared the ColoredRaisedButton button outside the render method. Isn't it the reason ?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.