Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boardRepository.updateData(data); #39

Open
amalmajeed opened this issue Mar 27, 2022 · 0 comments
Open

boardRepository.updateData(data); #39

amalmajeed opened this issue Mar 27, 2022 · 0 comments

Comments

@amalmajeed
Copy link

amalmajeed commented Mar 27, 2022

Not exactly an issue, but could you elaborate on how to use the 'boardRepository.updateData(data);'. It seems that after I update the dictionary object 'data' with a new value and try and update this using a button press, data is not getting updated.

`
import { StatusBar } from 'expo-status-bar';
import React, {useState} from 'react';
import { SafeAreaView, StyleSheet, Text, View, Image, TextInput, TouchableOpacity } from 'react-native';
// @ts-ignore
import { BoardRepository, Board } from 'react-native-draganddrop-board';

export default function App() {
const [txt,setTxt] = useState("");
var data = [
{
id: 1,
name: 'TO DO',
idcount: 0,
rows: []
},
{
id: 2,
name: 'IN PROGRESS',
idcount: 0,
rows: []
},
{
id: 3,
name: 'DONE',
idcount: 0,
rows: []
}
]

const boardRepository = new BoardRepository(data);

const addTask = (taskName) =>{
console.log("Adding task");
data[0].idcount = data[0].idcount + 1;
console.log("Step 1 done");
var task = {id: data[0].idcount.toString(), name:taskName};
console.log("Step 2 done");
data[0].rows.push(task);
console.log("Step 3 done");
console.log(data);
boardRepository.updateData(data); // THIS IS THE LINE WHERE I UPDATE, THE BOARD IS NOT RE-RENDERING
}

return (


<Image style ={{ transform:[{scale:0.27}],}} source = {require('./assets/Kanban-board-1.png')}>


<Board
boardRepository={boardRepository}
open={() => {}}
onPress={() => {}}
onDragEnd={() => {}}
/>


<TextInput style={styles.input}
onChangeText={newText => setTxt(newText)}
placeholder="Enter new to do task here" />
<TouchableOpacity
onPress={() => {
addTask(txt);
}}>
<Image source = {require('./assets/add_task.png')}>



);
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant