inProgress-team / inProgress-team/react-native-meteor

Use function component.React new feature HOOKS.how to use with it?

Open
#355 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
688
Forks
200
PR merge metrics
No merged PRs in 30d

Description

Can you give me the example of a function component?
I don't use class components.
So what can I do? If I want to use meteor subscribe
I use like that
```js
import React, { useState } from "react";
import { View, Text } from "react-native";
import {
Container,
Header,
Content,
Form,
Item,
Input,
Label,
Button,
Text
} from "native-base";
// meteor
import Meteor, { withTracker, MeteorListView } from "react-native-meteor";

Meteor.connect("ws://192.168.1.100:3000/websocket"); //do this only once

let f = {
name: "Bona",
age: 20
};
export default () => {
const [form, setForm] = useState(f);
function btnRegister() {
let doc = {
name: form.name,
age: Number(form.age)
};
Meteor.call("insertCustomer", doc, (err, result) => {
if (result) {
console.log("inserted", result);
} else {
console.log("err", err);
}
});
}
return (





Username
setForm({ ...form, name: value })}
/>


Age
setForm({ ...form, age: value })}
/>



Register





);
};

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.